计算颜色轮周围较长的两种颜色之间的颜色渐变点

时间:2021-03-12 11:32:17

标签: javascript colors gradient

看到这个问题 Calculate the color at a given point on a gradient between two colors? 我在这里引用了一个非常简单且有效的解决方案:

// You simply linearly interpolate the red, the green, and the blue channels like this:

resultRed = color1.red + percent * (color2.red - color1.red);
resultGreen = color1.green + percent * (color2.green - color1.green);
resultBlue = color1.blue + percent * (color2.blue - color1.blue);

// where percent is a value between 0 and 1 indicating the desired relative 
// location between color1 and color2.

在原始问题的示例中,渐变从红色到蓝色,再到您通常预期的紫色。

现在,如果您想从红色变为蓝色围绕色轮的另一(更长)方式,通过橙色、黄色、绿色,您如何计算渐变点?

0 个答案:

没有答案