我正在尝试建立一个调色板约2种颜色:青色和玫瑰色
我找到了这个网站:https://learnui.design/tools/data-color-picker.html#palette
它可以完成我所要查找的一半,所以我想用python中的matplotlib
、seaborn
、palettable
和/或{
有没有一种方法来插值下一种颜色将被赋予一系列渐变色?
例如,我在网站上给出了start_color
和{start_color
到end_color
。有没有办法做到这一点,但使end_color
成为middle_color
,并继续渐变?在
我想让青色start_color
保持第一种颜色,使玫瑰end_color
成为{
我想试着得到RGB值,然后做一些建模来找出它会往哪里去,但我想可能有一个更简单的方法来做到这一点。在
您可以将颜色视为颜色空间中的一个点,该空间通常由三个或四个维度组成,如RGB或HSL。要在这个空间中的两个点之间创建线性插值,只需遵循这两点创建的直线即可。根据颜色空间的不同,你会得到不同的颜色延续。在
下面,我使用
matplotlib
来显示选项板,colormath
用于可以通过pip install colormath
安装的转换。这座图书馆使这项工作比以前容易得多。在线性外推的基本思想是简单地扩展由两种颜色定义的向量。最大的问题是当我们碰到颜色空间的“墙”时。例如,考虑颜色空间RGB,其中红色从0变为255。插值线碰到255墙后会发生什么?一种颜色不能比红色更红。我认为你可以继续的一种方法是将这条线视为一束光线,它可以“反弹”或“反射”出rgb空间的墙壁。在
有趣的是,
^{pr2}$colormath
似乎并不介意其颜色对象的参数超出其限制。它继续创建一个具有无效十六进制值的color对象。这有时会在外推法中发生。为了防止这种情况发生,我们可以设置RGB值的上限:或者让它从墙上“反射”回来。在
上面的等式应该是不言自明的。当一个RGB通道降到零下时,翻转它的标志以“反射”离开零壁,同样,当它超过1时,将其反射回零。以下是使用该方法的一些外推结果:
请注意,因为色调是一个圆形轴,在HSV或HSL这样的颜色空间中,它会绕回来,如果您将结束颜色放在调色板的中间,您可能会返回到接近开始颜色的位置。在
看到这些插值在颜色空间中的路径是非常迷人的。看看吧。请注意,从墙上反弹产生的效果。在
我可能会在某个时候把它变成一个开源项目。在
这里有一个解决方案,只在RGB颜色空间中的颜色之间进行简单的插值。这有问题。。。RGB中颜色之间的欧几里得距离与人类的感知没有直接关系。所以。。。如果你真的想成为一个(以一种好的方式)关于你的颜色是如何被感知的专家,你可能想进入实验室或HCL做这样的事情。在
这些不是最好的裁判,但他们提供了一些关于这种现象的东西,我想。。。在
所以。。。把警告放在一边。。。这里有一个RGB的解决方案,但在实验室或HCL中可能更好。:)
助手/设置
创建调色板
^{pr2}$看起来像这样:
如果使用RGB颜色,则可以找到矢量并对其进行缩放:
例如(0,147,146)+(2/4*(208,-59,-20))=(104117.5136)
相关问题 更多 >
编程相关推荐