我使用的更少,我想利用各种集成的颜色功能,允许设置只有少数基本颜色,然后派生其他改变色调,饱和度,明度,旋转,ECC。
让我们假设在我的着色器中有以下两种颜色(本例中为浅绿色和深绿色):
@primary-color: rgb(0,100,60);
@secondary-color: rgb(185,215,50);
附注:如果有必要,也可以借助Photoshop等外部工具。
下面是计算两种颜色的色调、饱和度和明度值之间的差值,然后用它来计算基于第一种颜色的第二种颜色。
具体步骤如下:
色调()
、饱和度()
和亮度()
函数计算两种给定颜色之间的色调、饱和度和亮度差异。此函数可以单独使用,仅用于单独输出差异。spin()
函数调整原色的色相saturate()
或desaturate()
函数调整色调调整后的颜色的饱和度(从上一步开始)。darken()
或lighten()
函数调整饱和度调整颜色的亮度(从上一步开始)。@primary: rgb(0,100,60); /* primary color */
@secondary: rgb(185,215,50); /* secondary color */
/* mixin to calculate the difference between two given colors */
.color-diff(@color1; @color2){
@hueDiff: hue(@color2) - hue(@color1);
@saturationDiff: saturation(@color1) - saturation(@color2);
@lightnessDiff: lightness(@color1)- lightness(@color2);
color1: @color1; color2:@color2; /* just for testing, can be removed */
}
/* Step 1: mixin to adjust the hue difference between the colors */
.adjust-hue(@color; @diff){
@hueAdjusted: spin(@color, @hueDiff);
}
/* Step 2: mixin to adjust the saturation difference */
.adjust-saturation(@color; @diff) when (@diff > 0){
@satAdjusted: desaturate(@color, abs(@diff)); /* desaturate if diff is greater than 0 */
}
.adjust-saturation(@color; @diff) when not (@diff > 0){
@satAdjusted: saturate(@color, abs(@diff)); /* saturate if diff is not greater than 0 */
}
/* Step 3: mixin to adjust the lightness diff between the colors */
.adjust-lightness(@color; @diff) when (@diff > 0){
@lightnessAdjusted: darken(@color, abs(@diff)); /* darken if diff is greater than 0 */
}
.adjust-lightness(@color; @diff) when not (@diff > 0){
@lightnessAdjusted: lighten(@color, abs(@diff)); /* else lighten */
}
div{
.color-diff(@primary; @secondary);
.adjust-hue(@primary; @hueDiff);
.adjust-saturation(@hueAdjusted; @saturationDiff);
.adjust-lightness(@satAdjusted; @lightnessDiff);
color: @lightnessAdjusted; /* final output value */
}
div {
color1: #00643c;
color2: #b9d732;
color: #b9d732;
}
@color-list-1: rgb(0,100,60), #B0BCA7, #ABCDEF; /* list of primary colors */
@color-list-2: rgb(185,215,50), #BADA55, #FEDCBA; /* list of secondary colors */
#output{
.loop-colors(@index) when (@index > 0){
@primary: extract(@color-list-1, @index);
@secondary: extract(@color-list-2, @index);
.color-diff(@primary; @secondary);
/* output the values of the comparison */
color-comparison-@{index}+: ~"Hue Difference: @{hueDiff}";
color-comparison-@{index}+: ~"Saturation Difference: @{saturationDiff}";
color-comparison-@{index}+: ~"Lightness Difference: @{lightnessDiff}";
.loop-colors(@index - 1);
}
.loop-colors(length(@color-list-1));
}
上面的代码将比较两个列表中对应的值,并输出它们的差异,如下所示:
#output {
color-comparison-3: Hue Difference: -180, Saturation Difference: -29.142857142857153%, Lightness Difference: -5.882352941176478%;
color-comparison-2: Hue Difference: -19.849624060150404, Saturation Difference: -50.70282063269439%, Lightness Difference: 10.196078431372548%;
color-comparison-1: Hue Difference: -85.09090909090908, Saturation Difference: 32.65306122448979%, Lightness Difference: -32.352941176470594%;
}
老友记.我有两个DIVS。在一个div中,我有几个列表项“li”。我想做的是,每次我悬停在div 1的li上时,我想改变div 2的背景颜色。为此我需要使用css。谢谢. 你好 null 所以我想要的是,当悬停在id为“red”的li上时,将类为“contents”的div的背景颜色更改为红色。使用CSS。这是我的全部Html文件。
问题内容: 所以我有一个带有火山的图像文件。其他所有内容均为0xFFFF00FF(不透明的洋红色)。我想将包含该颜色的每个像素替换为0(透明)。到目前为止,我的方法如下所示: 这工作正常,但似乎很慢。我见过有人以其他方式执行此操作,但是我不知道发生了什么。如果有人知道更好的方法,我非常想听听。 问题答案: 为了避免遍历像素,请更改基础ColorModel。这是一个例子。以下是作者使用原始Buffe
本文向大家介绍Python 实现一个颜色色值转换的小工具,包括了Python 实现一个颜色色值转换的小工具的使用技巧和注意事项,需要的朋友参考一下 需求说明 公司的 UI 设计小哥,已经转用 Zeplin 很久了。Zeplin 的设计稿展示页面的颜色色值使用十进制的 RGB 表示的,在 Android 中的颜色表示大多情况下都需要十六进制的 RGB 表示。我的数学没有好到直接看到十进制就可
我使用JQuery设置一个带有随机颜色的悬停,通过这个代码,如果我移动鼠标,就可以在同一个div中设置几种颜色。 我的目标是每次在同一个div中只有一种固定的颜色,如果鼠标不离开div,颜色必须保持不变? 请问你有什么主意吗? null null
问题内容: 我正在开发一个捕获屏幕快照并从捕获的图像创建视频的应用程序。但是问题在于,当生成视频时,生成的视频中的颜色非常粉红色。我认为这是因为我正在使用BufferedImage.TYPE_3BYTE_BGR类型操纵捕获的图像以显示光标。有人可以告诉我如何解决此问题,我希望视频的颜色与屏幕的实际颜色相同。 为了捕获屏幕图像,我正在执行以下操作: 对于操作图像,我正在做如下操作: 请告诉我如何获取
RGB转十六进制Hex rgbToHex(rgb) 该函数可以将一个RGB颜色值转换成一个Hex的十六进制颜色值 rgb <String> RGB颜色值,如rgb(230, 231, 233) export default{ data() { return { rgb: 'rgb(13, 145, 20)' } }, onLoad() { console.log(this.
问题内容: 我在Python中使用matplotlib在一个数组中,其浮点数介于0到1之间。 我正在用imshow显示此数组,我试图创建一个与Greens相同的自定义cmap,但是当一个单元格变为0时,我希望能够将该值映射为红色,而其余光谱不变。 如果有人更熟悉matplotlib能够帮助我,我将不胜感激! 例如,我将如何编辑此脚本,以使矩阵中的零值显示为红色? 问题答案: matplotlib中