Home  >  Article  >  Web Front-end  >  CSS basic tutorial---RGB additive color description

CSS basic tutorial---RGB additive color description

WBOY
WBOYOriginal
2016-05-16 12:06:462238browse

rgb colors are called additive colors because you create white by adding r, g, and b together (that is, all the light is reflected back to the eye). additive colors are used in lighting, televisions and computer monitors. for example, displays produce color by emitting light from red, green and blue phosphors.

the vast majority of the visible spectrum can be expressed as a mixture of red, green, and blue (rgb) colors of light in different proportions and intensities. when these colors overlap, cyan, magenta, and yellow are produced.

additional color (rgb)

r. red g. green b . blue
you can manipulate color values ​​by using the rgb color mode, which is based on the rgb color model. in rgb mode, each rgb component can take a value from 0 (black) to 255 (white). for example, a bright red uses an r value of 246, a g value of 20, and a b value of 50. when all three component values ​​are equal, a shade of gray is produced. when all components have a value of 255, the result is pure white; when the value is 0, the result is pure black.

the method of encoding a color is collectively called a "color space" or "color gamut". in the simplest terms, the "color space" of any color in the world can be defined as a fixed number or variable. rgb (red, green, blue) is just one of many color spaces. with this encoding method, each color can be represented by three variables - red, green, and the intensity of blue. when recording and displaying color images, rgb is the most common solution. however, it lacked good compatibility with early black and white display systems. therefore, a common practice adopted by many electronic and electrical manufacturers is to convert rgb into yuv color space to maintain compatibility, and then change back to rgb format as needed to display color graphics on computer monitors.

since web pages (web) are media developed based on computer browsers, the colors are mainly optical colors rgb (red, green, blue). web page color is represented by a hexadecimal code. the general format is #zyzabc (letters are replaced by numbers). for example, black has three colors of 0, and the web page code is: #000000. when the color code is #xxyyzz, it can be represented by #xyz. for example, #135 and #113355 represent the same color.

rgb()

the function will represent the three primary colors of red, green and blue the three integers are combined into a long integer representing the color.

syntax:

RGB ( red, green, blue )

parameters:

red: integer type, specifies the intensity of the red component in the color, valid values ​​are between 0 and 255

green: integer type, specifies the green component intensity in the color, the valid value is between 0 and 255

blue: integer type, specifies the blue component intensity in the color, the valid value is 0 return value long between 255 and 255.

when the function executes successfully, it returns the color determined by the specified component, expressed as a long integer. returns -1 on error. if the value of any parameter is null, the rgb() function returns null.

usage:

the rgb() function uses the following formula to calculate the long integer representing the color: 65536 * blue 256 * green red where blue represents the blue component and green represents the green component. , red represents the red component. among each component, the smaller the value, the lower the brightness, and the larger the value, the higher the brightness. for example, rgb (0, 0, 0) is black (the lowest brightness), and rgb (255, 255,255) is white (the highest brightness).

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn