RGB Colors
Table of Contents
- What is the RGB Color Model?
- Additive Color Composition
- Color Calculation
- Relationship with Other Color Models
- Conversion to Hexadecimal
- Basic Color Table
What is the RGB Color Model?
The RGB color model is an additive system in which red, green, and blue colors are combined to create a wide range of colors. This model is mainly used in digital displays, such as computer monitors, televisions, and mobile devices.
Additive Color Composition
In the RGB model, each color is represented as a combination of three components: red, green, and blue. Each of these components can vary in intensity from 0 (total absence of light) to 255 (maximum intensity). This means that a color in RGB is represented as a triplet of integers in the range of 0 to 255. For example, rgb(255, 0, 0)
represents pure red.
Color Calculation
The final color perceived is the result of adding the intensities of the three primary colors. Here are some examples:
- White: Achieved when all values are at maximum, i.e.,
rgb(255, 255, 255)
. - Black: Occurs when all values are zero, i.e.,
rgb(0, 0, 0)
. - Yellow: Created by combining red and green at their maximum intensities, i.e.,
rgb(255, 255, 0)
. - Magenta: The result of combining red and blue at their maximum intensities, i.e.,
rgb(255, 0, 255)
. - Cyan: Formed by combining blue and green at their maximum intensities, i.e.,
rgb(0, 255, 255)
.
Relationship with Other Color Models
The RGB model is additive, meaning that colors are generated by adding light. This differentiates it from the CMYK model, which is subtractive and used in printing. In CMYK, colors are created by subtracting light (i.e., adding ink) and are measured in terms of cyan, magenta, yellow, and black.
Conversion to Hexadecimal
RGB colors are often represented in hexadecimal code in the context of web development. Each component (red, green, blue) is converted to a two-digit hexadecimal value and concatenated into a six-digit string. For example, rgb(255, 165, 0)
becomes #FFA500
, which is the color orange.
Basic Colors in CSS
Color | Sample | RGB | Hexadecimal | CSS Name |
---|---|---|---|---|
White | rgb(255, 255, 255) | #FFFFFF | white | |
Black | rgb(0, 0, 0) | #000000 | black | |
Red | rgb(255, 0, 0) | #FF0000 | red | |
Green | rgb(0, 255, 0) | #00FF00 | lime | |
Blue | rgb(0, 0, 255) | #0000FF | blue | |
Yellow | rgb(255, 255, 0) | #FFFF00 | yellow | |
Cyan | rgb(0, 255, 255) | #00FFFF | cyan | |
Magenta | rgb(255, 0, 255) | #FF00FF | magenta | |
Gray | rgb(128, 128, 128) | #808080 | gray |