SCSS Blend Modes 技术文档
2024-12-24 21:51:49作者:胡唯隽
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
插件来实现颜色混合效果。
登录后查看全文
热门项目推荐
- QQwen3-Next-80B-A3B-InstructQwen3-Next-80B-A3B-Instruct 是一款支持超长上下文(最高 256K tokens)、具备高效推理与卓越性能的指令微调大模型00
- QQwen3-Next-80B-A3B-ThinkingQwen3-Next-80B-A3B-Thinking 在复杂推理和强化学习任务中超越 30B–32B 同类模型,并在多项基准测试中优于 Gemini-2.5-Flash-Thinking00
GitCode-文心大模型-智源研究院AI应用开发大赛
GitCode&文心大模型&智源研究院强强联合,发起的AI应用开发大赛;总奖池8W,单人最高可得价值3W奖励。快来参加吧~093Sealos
以应用为中心的智能云操作系统TSX00GitCode百大开源项目
GitCode百大计划旨在表彰GitCode平台上积极推动项目社区化,拥有广泛影响力的G-Star项目,入选项目不仅代表了GitCode开源生态的蓬勃发展,也反映了当下开源行业的发展趋势。08- HHunyuan-MT-7B腾讯混元翻译模型主要支持33种语言间的互译,包括中国五种少数民族语言。00
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).Dockerfile01
- PpathwayPathway is an open framework for high-throughput and low-latency real-time data processing.Python00
- Dd2l-zh《动手学深度学习》:面向中文读者、能运行、可讨论。中英文版被70多个国家的500多所大学用于教学。Python011
热门内容推荐
1 freeCodeCamp猫照片应用教程中的HTML注释测试问题分析2 freeCodeCamp全栈开发课程中测验游戏项目的参数顺序问题解析3 freeCodeCamp英语课程填空题提示缺失问题分析4 freeCodeCamp音乐播放器项目中的函数调用问题解析5 freeCodeCamp论坛排行榜项目中的错误日志规范要求6 freeCodeCamp 课程中关于角色与职责描述的语法优化建议 7 freeCodeCamp全栈开发课程中React组件导出方式的衔接问题分析8 freeCodeCamp Cafe Menu项目中link元素的void特性解析9 freeCodeCamp全栈开发课程中React实验项目的分类修正10 freeCodeCamp英语课程视频测验选项与提示不匹配问题分析
最新内容推荐
OMNeT++中文使用手册:网络仿真的终极指南与实用教程 基于Matlab的等几何分析IGA软件包:工程计算与几何建模的完美融合 PADS元器件位号居中脚本:提升PCB设计效率的自动化利器 电脑PC网易云音乐免安装皮肤插件使用指南:个性化音乐播放体验 Python Django图书借阅管理系统:高效智能的图书馆管理解决方案 Python开发者的macOS终极指南:VSCode安装配置全攻略 WebVideoDownloader:高效网页视频抓取工具全面使用指南 ReportMachine.v7.0D5-XE10:Delphi报表生成利器深度解析与实战指南 PhysioNet医学研究数据库:临床数据分析与生物信号处理的权威资源指南 海康威视DS-7800N-K1固件升级包全面解析:提升安防设备性能的关键资源
项目优选
收起

React Native鸿蒙化仓库
C++
187
266

openGauss kernel ~ openGauss is an open source relational database management system
C++
138
188

🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
892
529

旨在打造算法先进、性能卓越、高效敏捷、安全可靠的密码套件,通过轻量级、可剪裁的软件技术架构满足各行业不同场景的多样化要求,让密码技术应用更简单,同时探索后量子等先进算法创新实践,构建密码前沿技术底座!
C
370
387

Git4Research旨在构建一个开放、包容、协作的研究社区,让更多人能够参与到科学研究中,共同推动知识的进步。
HTML
19
0

deepin linux kernel
C
22
6

本仓将收集和展示高质量的仓颉示例代码,欢迎大家投稿,让全世界看到您的妙趣设计,也让更多人通过您的编码理解和喜爱仓颉语言。
Cangjie
337
1.11 K

为仓颉编程语言开发者打造活跃、开放、高质量的社区环境
Markdown
1.08 K
0

一款跨平台的 Markdown AI 笔记软件,致力于使用 AI 建立记录和写作的桥梁。
TSX
84
4

harmony-utils 一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。
ArkTS
63
2