Color VI in the computer-fast computing from the color phase value to the solid color

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.