SCSS Blend Modes 技术文档
2024-12-24 12:58:23作者:胡唯隽
1. 安装指南
1.1 安装 Ruby Gem
首先,你需要安装 compass-blend-modes 这个 Ruby Gem。你可以通过以下命令进行安装:
gem install compass-blend-modes
1.2 在现有 Compass 项目中使用
如果你已经有一个 Compass 项目,可以通过在 config.rb 文件中添加以下代码来引入插件:
# Require any additional compass plugins here.
require 'compass-blend-modes'
1.3 在新 Compass 项目中使用
如果你正在创建一个新的 Compass 项目,可以在创建项目时直接安装插件:
compass create my_project -r compass-blend-modes
2. 项目使用说明
2.1 导入 SCSS 文件
在你的 SCSS 文件中,首先需要导入 blend-modes 文件:
@import 'blend-modes';
2.2 使用示例
以下是一些使用示例,展示了如何在项目中使用不同的混合模式:
// 确保导入了混合模式函数
@import 'blend-modes';
// 纯色背景
.multiply {
background-color: blend-multiply(#7FFFD4, #DEB887);
}
// RGBa 背景
.multiply {
background-color: blend-multiply(rgba(#7FFFD4, 0.5), rgba(#DEB887, 0.5));
}
3. 项目 API 使用文档
3.1 混合模式函数
所有的混合模式函数都接受两个颜色参数:$foreground(前景色)和 $background(背景色)。颜色可以是任何 Sass 支持的格式,包括十六进制、RGB、RGBA、HSL 或 HSLA。混合模式函数通过将前景色与背景色结合来实现颜色混合。
- blend-normal($foreground, $background) - 主要用于在混合后保留透明度。
- blend-multiply($foreground, $background)
- blend-lighten($foreground, $background)
- blend-darken($foreground, $background)
- blend-darkercolor($foreground, $background) - Photoshop 中没有此模式。
- blend-lightercolor($foreground, $background) - Photoshop 中没有此模式。
- blend-lineardodge($foreground, $background)
- blend-linearburn($foreground, $background)
- blend-difference($foreground, $background)
- blend-screen($foreground, $background)
- blend-exclusion($foreground, $background)
- blend-overlay($foreground, $background)
- blend-softlight($foreground, $background)
- blend-hardlight($foreground, $background)
- blend-colordodge($foreground, $background)
- blend-colorburn($foreground, $background)
- blend-linearlight($foreground, $background)
- blend-vividlight($foreground, $background)
- blend-pinlight($foreground, $background)
- blend-hardmix($foreground, $background)
- blend-colorblend($foreground, $background)
- blend-dissolve($foreground, $background) - 未实现。Dissolve 将透明度视为像素图案,并应用扩散抖动图案。
- blend-divide($foreground, $background)
- blend-hue($foreground, $background)
- blend-luminosity($foreground, $background)
- blend-saturation($foreground, $background)
- blend-subtract($foreground, $background)
3.2 HSV 函数
这些函数用于在 RGB、HSL 和 HSV 颜色格式之间进行转换。HSV 颜色格式在 CSS 或 Sass 中并不原生支持。这些函数直接取自 Gist。HSV 值用于计算 blend-colorblend、blend-hue、blend-luminosity 和 blend-saturation 函数的结果。
- **hsv-to-hsl(s: 0, h
可以是表示s和$v` 的三个值的列表。 - **hsl-to-hsv(ss: 0, h
可以是表示ss和$ll` 的三个值的列表。 - color-to-hsv($color) - 将 Sass 颜色转换为 HSV 颜色值的列表。
- **hsv-to-color(s: 0, h
可以是表示s和$v` 的三个值的列表。
3.3 内部函数
这些函数用于减少冗余代码,不建议直接使用。它们在单个 r、g 或 b 值上执行混合操作。
注意: 这些函数不打算直接使用。
- blend-lighten-color($foreground, $background)
- blend-darken-color($foreground, $background)
- blend-lineardodge-color($foreground, $background)
- blend-linearburn-color($foreground, $background)
- blend-screen-color($foreground, $background)
- blend-exclusion-color($foreground, $background)
- blend-overlay-color($foreground, $background)
- blend-softlight-color($foreground, $background)
- blend-hardlight-color($foreground, $background)
- blend-colordodge-color($foreground, $background)
- blend-colorburn-color($foreground, $background)
- blend-linearlight-color($foreground, $background)
- blend-vividlight-color($foreground, $background)
- blend-pinlight-color($foreground, $background)
- blend-hardmix-color($foreground, $background)
- blend-divide-color($foreground, $background)
4. 项目安装方式
4.1 通过 Ruby Gem 安装
你可以通过以下命令安装 compass-blend-modes 插件:
gem install compass-blend-modes
4.2 在现有 Compass 项目中引入
在现有 Compass 项目的 config.rb 文件中添加以下代码:
require 'compass-blend-modes'
4.3 在新 Compass 项目中安装
在创建新 Compass 项目时,可以通过以下命令安装插件:
compass create my_project -r compass-blend-modes
通过以上步骤,你可以在项目中使用 compass-blend-modes 插件来实现颜色混合效果。
登录后查看全文
热门项目推荐
相关项目推荐
PaddleOCR-VLPaddleOCR-VL 是一款顶尖且资源高效的文档解析专用模型。其核心组件为 PaddleOCR-VL-0.9B,这是一款精简却功能强大的视觉语言模型(VLM)。该模型融合了 NaViT 风格的动态分辨率视觉编码器与 ERNIE-4.5-0.3B 语言模型,可实现精准的元素识别。Python00
unified-cache-managementUnified Cache Manager(推理记忆数据管理器),是一款以KV Cache为中心的推理加速套件,其融合了多类型缓存加速算法工具,分级管理并持久化推理过程中产生的KV Cache记忆数据,扩大推理上下文窗口,以实现高吞吐、低时延的推理体验,降低每Token推理成本。Python03
MiniCPM-V-4_5MiniCPM-V 4.5 是 MiniCPM-V 系列中最新且功能最强的模型。该模型基于 Qwen3-8B 和 SigLIP2-400M 构建,总参数量为 80 亿。与之前的 MiniCPM-V 和 MiniCPM-o 模型相比,它在性能上有显著提升,并引入了新的实用功能Python00
HunyuanWorld-Mirror混元3D世界重建模型,支持多模态先验注入和多任务统一输出Python00
MiniMax-M2MiniMax-M2是MiniMaxAI开源的高效MoE模型,2300亿总参数中仅激活100亿,却在编码和智能体任务上表现卓越。它支持多文件编辑、终端操作和复杂工具链调用Python00
Spark-Scilit-X1-13B科大讯飞Spark Scilit-X1-13B基于最新一代科大讯飞基础模型,并针对源自科学文献的多项核心任务进行了训练。作为一款专为学术研究场景打造的大型语言模型,它在论文辅助阅读、学术翻译、英语润色和评论生成等方面均表现出色,旨在为研究人员、教师和学生提供高效、精准的智能辅助。Python00
GOT-OCR-2.0-hf阶跃星辰StepFun推出的GOT-OCR-2.0-hf是一款强大的多语言OCR开源模型,支持从普通文档到复杂场景的文字识别。它能精准处理表格、图表、数学公式、几何图形甚至乐谱等特殊内容,输出结果可通过第三方工具渲染成多种格式。模型支持1024×1024高分辨率输入,具备多页批量处理、动态分块识别和交互式区域选择等创新功能,用户可通过坐标或颜色指定识别区域。基于Apache 2.0协议开源,提供Hugging Face演示和完整代码,适用于学术研究到工业应用的广泛场景,为OCR领域带来突破性解决方案。00- HHowToCook程序员在家做饭方法指南。Programmer's guide about how to cook at home (Chinese only).Dockerfile014
Spark-Chemistry-X1-13B科大讯飞星火化学-X1-13B (iFLYTEK Spark Chemistry-X1-13B) 是一款专为化学领域优化的大语言模型。它由星火-X1 (Spark-X1) 基础模型微调而来,在化学知识问答、分子性质预测、化学名称转换和科学推理方面展现出强大的能力,同时保持了强大的通用语言理解与生成能力。Python00- PpathwayPathway is an open framework for high-throughput and low-latency real-time data processing.Python00
最新内容推荐
Launch4j中文版:Java应用程序打包成EXE的终极解决方案 海康威视DS-7800N-K1固件升级包全面解析:提升安防设备性能的关键资源 高效汇编代码注入器:跨平台x86/x64架构的终极解决方案 Solidcam后处理文件下载与使用完全指南:提升CNC编程效率的必备资源 电脑PC网易云音乐免安装皮肤插件使用指南:个性化音乐播放体验 32位ECC纠错Verilog代码:提升FPGA系统可靠性的关键技术方案 海能达HP680CPS-V2.0.01.004chs写频软件:专业对讲机配置管理利器 CS1237半桥称重解决方案:高精度24位ADC称重模块完全指南 ReportMachine.v7.0D5-XE10:Delphi报表生成利器深度解析与实战指南 瀚高迁移工具migration-4.1.4:企业级数据库迁移的智能解决方案
项目优选
收起
deepin linux kernel
C
24
7
OpenHarmony documentation | OpenHarmony开发者文档
Dockerfile
291
2.62 K
Ascend Extension for PyTorch
Python
122
149
暂无简介
Dart
579
127
React Native鸿蒙化仓库
JavaScript
227
306
仓颉编译器源码及 cjdb 调试工具。
C++
121
345
仓颉编程语言运行时与标准库。
Cangjie
130
358
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
1.05 K
610
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
606
184
openGauss kernel ~ openGauss is an open source relational database management system
C++
155
205