Image programming in ACTIONSCRIPT3 games (serial 17)

Source: Internet
Author: User

Total folders: http://blog.csdn.net/iloveas2014/article/details/38304477

1.3.3 between HSB and RGB and similarities and differences between HSL and HSV in the understanding of color attributes

First, HSL and HSV have a consistent definition of H, with formulas such as the following:

Max=min means that the r,g,b three values are always equal, only can be white, gray, black these three kinds of colors, the hue value in such a case no matter what meaning, so let it equals 0.

The HSB mode then divides the hue ring into three 120-degree intervals (figure 1.28).

Fig. 1.28 Interval distribution of the Hue ring


[0,60] U[300,360] is the red interval, [60,180] is the green interval, [180,300] is the blue interval. It is easy to infer the H value of the RGB color in which color range it is, as long as you see which channel reflects the maximum shade. Red is divided into two sides, so when the hue in the red zone to add a condition, but it is not complicated, because the h-axis itself is a ring structure, the left side and the right side is actually coincident, so this step of the inference is to standardize the calculated angle, so that it fell in [0, 360] Within the range without negative numbers. So when Max=r, the formula can be combined such as the following:

(60* (G-b)/(max-min) +360)%360.

However, when tapping the code, it is usually inferred to deal with, because the remainder of the operating efficiency is worse.

Then look at the calculation methods for the L and s in HSL:


It can be seen that only Max and Min are taken to the maximum of the channel, that is, when the required r=g=b=255, brightness to reach the maximum, in other words, HSL mode, only white is the biggest brightness, which is the same as HSL color space.

Max=min or l=0 means r=g=b, when the color is only white, gray, black, naturally there is no saturation.

The formula for the V and S in the HSV is as follows:

As the physical meaning is the brightness of V, it is required to reach the maximum value is lower than the HSL mode, RGB three channels only one to take 255, the brightness reaches the maximum value. This difference may result in different results in different patterns described in the two colors of the light and shade differences. That is, color A and color B appear L (a) >l (b), but V (a) <v (b).

The definition of saturation is 0, there is no difference between the two modes, and the saturation calculation rules are based on the difference of the R,g,b channel value as the basic determinant, and then divided by the brightness to standardize the results. Then, due to the difference in brightness calculation, L color range is one times greater than V, so the divisor of the HSL pattern must be equal to twice times the brightness of the ability to cancel, plus a brighter color, HSV and HSL in the saturation of the lack of consensus, HSL mode s formula will write the component segment function.

and HSV/HSL to RGB is the inverse of RGB to HSV/HSL, although in some extreme conditions, such operations are not reversible, but rest assured that these problems will not affect your use of color.

For example h250,s60,l100 and h300,s50,l100, go to RGB are r255,g255,b255, this time back to HSL is h0,s0,l100, the value is changed, but the result value is always white. This is similar to the latitude and longitude of the Earth at the pole position.

Image programming in ACTIONSCRIPT3 games (serial 17)

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.