In the previous article, we introduced "How to quickly calculate the color phase value". This article introduces the calculation process from the color phase value to the solid color. As mentioned earlier, the color and solid color have a one-to-one relationship. Let's take a look at the traditional calculation method:
The calculation process is complicated. Let's look at the color distribution chart of the solid color.
Find the rule. In the right shadow part of the graph, the variation of each component is as follows:
0-60: R: 255-255; G: 0-255; B: 0-0;
60-120: R: 255-"0; G: 255-" 255; B: 0-"0;
120-180: R: 0-0; G: 255-255; B: 0-255;
The left half blank part in the figure is calculated from the red angle. The changes of each component are as follows:
0-60: R: 255-255; G: 0-0; B: 0-255;
60-120: R: 255-"0; G: 0-" 0; B: 255-"255;
120-180: R: 0-0; G: 0-255; B: 255-255;
Looking at the two changes above, we can find that the changes in R are consistent, while the changes in G and B are just about symmetric. Therefore, as long as you can write the formula on the right and swap the values of G and B, you can get the formula on the left.
The formula on the right is described as follows:
Take the angle between the solid color and the red color, and the right side is the color phase value θ of the solid color.
Lambda = θ/60 × 255
R = 510-λ; if r <0, r = 0; if r> 255, r = 255;
G = λ; G = 255 If G> 255;
B = Lambda-510; B = 0 if B <0;
The calculated solid color (R, G, B) is the solid color corresponding to the color value.
Similarly, the formula is slightly transformed, that is, the formula on the left:
Take the angle between the solid color and the red color. The left side is 360-θ.
Lambda = θ/60 × 255
R = 510-λ; if r <0, r = 0; if r> 255, r = 255;
G = λ-510; G = 0 if G <0;
B = λ; if B> 255, B = 255;
In summary, the two formulas are the rapid calculation from the color phase value to the solid color.