Documentation/Calc Functions/COLOR
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Function name:
COLOR
Category:
Mathematical
Summary:
Combines specified values of the red, green, blue, and alpha channels of an RGBA color representation to produce a single encoded value.
Syntax:
COLOR(Red; Green; Blue[; Alpha])
Returns:
Returns an integer in the range [0, 232-1] that is the color value constructed from the specified components.
Arguments:
Red is an integer in the range [0, 255], or a reference to a cell containing that number, that is the intensity of the red color.
Green is an integer in the range [0, 255], or a reference to a cell containing that number, that is the intensity of the green color.
Blue is an integer in the range [0, 255], or a reference to a cell containing that number, that is the intensity of the blue color.
Alpha is an integer in the range [0, 255], or a reference to a cell containing that number, that is the value for the alpha channel. If omitted, a default value of 0 is applied. A value of 0 means that the color is fully transparent, whereas a value of 255 gives a fully opaque color.
- If any argument is non-numeric, then COLOR reports a #VALUE! error.
- If any argument is a non-integer value, then COLOR converts it to an integer by taking its floor value.
- If any argument is less than 0 or greater than 255, then COLOR reports an invalid argument error (Err:502).
Additional details:
- The value returned by COLOR has the alpha sample in its most significant 8 bits, followed by the red sample, green sample and finally the blue sample in the least significant 8 bits.
- COLOR combines the samples using the following formula:[math]\displaystyle{ \text{COLOR}(red, green, blue, alpha)~=~256*256*256*alpha~+~ 256*256*red~+~256*green~+~blue }[/math]
- 232 is equal to 4294967296.
Examples:
Formula | Description | Returns |
---|---|---|
=COLOR(255; 255; 255; 255) | All components take their maximum values and COLOR returns the value 4294967295 (hex 0xFFFFFFFF). | 4294967295 |
=COLOR(D1; D2; D3; D4) where cells D1, D2, D3, and D4 all contain the number 119. | All components take the value 119 and COLOR returns the value 2004318071 (hex 0x77777777). | 2004318071 |
=COLOR(119.2; 119.7; 119.5; 119.9) | COLOR takes the floor value of each argument. After truncation, all components take the value 119 and COLOR returns the value 2004318071 (hex 0x77777777). | 2004318071 |
=COLOR(255; 255; 255) | Here no value for the alpha channel is specified and the default value of 0 is assumed. COLOR returns the value 16777215 (hex 0x00FFFFFF). | 16777215 |
=COLOR(11; 12; 13; 10) | This example is useful to confirm how the function constructs the coded value by viewing its structure in hexadecimal format. COLOR returns the value 168496141 (hex 0x0A0B0C0D). | 168496141 |
Related LibreOffice functions:
None.
ODF standard:
None.
Related (or similar) Excel functions:
None.