Color VIII in computer-Rapid Calculation of color deflection

Source: Internet
Author: User

The deflection of solid color is introduced in "color VII in computer-Rapid Calculation of deflection of solid color.

This article expands the formula above to any color.

Color (R, G, B) how to calculate the deflection color (R', G', B ') after the ω deflection ')

The specific derivation process is not detailed in detail. It is similar to the previous article. The following describes the computing process:

Make Max the maximum values of the three components R, G, and B, and min the minimum values of the three components R, G, and B.

If max = min, the color is gray, no matter how the deflection, or the original color.

R' = r; G' = g; B '= B

If max = min, P = MAX-MIN

When G <B, ω =-ω

ω '= ω/60 × P

λ '= MAX-R + G-MIN + B-MIN + ω'

When λ '<0, set λ ''=-λ'

When λ '> 3 P, set λ ''to 6 p-λ'

Otherwise, λ ''= λ'

Deflection component of solid color

R' = 2 P-λ ''; If R' <0, R' = 0; If R'> P, R' = P;

G' = λ ''; If G'> P, G' = P;

B '= λ ''-2 p; If B' <0; then B '= 0;

If (G <B) XOR (λ '<0 or λ'> 3 P) = true, the values of G' and B 'are exchanged.

Last

R' = R' + min

G' = G' + min

B '= B' + min

(133, 44, 20) What is the color of clockwise Deflection? The answer is (20,120, 66)

(133, 44, 20) What is the color of the counterclockwise deflection? The answer is (120)

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.