COLOR function
TextualColor
A textual version of the color to return.
Returns
A color corresponding to the given textual color.
Returns a color based on the given parameter.
Here are a few examples of supported parameter values:
-
red
-
lime
-
black
-
white
-
antiquewhite
-
red 500
-
Deep Purple A700
-
#f44336
-
#0091ea
-
#acc
-
rgb(255, 0, 0)
-
rgb 255, 0, 0
-
rgb 100%, 0, 0
-
hsb 100%, 50%, 100%
-
hsb 255, 128, 255
-
hsv 100%, 50%, 100%
-
hsv 255, 128, 255
-
hsv 255 128 100%
-
hsv(255 128 255)
-
hsl 255 100% 100%
Refer to our appearance guide for much more information on colors. This function is Calcapp-specific.
Details
A number of different textual color formats are supported by the parameter, which is case-insensitive:
- Named colors. Named colors may be given. Examples include "red" and "rebeccapurple". These named colors can also be written as Color.RedColor,Red and Color.RebeccaPurpleColor,RebeccaPurple.
- Material Design colors. Colors that make up the Material Design palette are recognized. Examples include "Red 500", "Deep Purple 900" and "Blue A700". Material Design colors can also be written as Color.Red500Color,Red500 and Color.BlueA700Color,BlueA700.
- Hex notation. Colors specified using hex notation encode the red, green and blue color components using base 16, with a leading hash symbol ("#"). The color components are encoded as one byte each, in the following order: red, green, blue and, optionally, alpha (which specifies the degree to which the color is transparent). While each color component is normally expected to occupy two characters (as two characters are necessary to encode a byte using hex notation), there is also support for specifying a color component as only one character. In that case, the one character given for a color component is interpreted as though two such characters were given, meaning that "#cca" is interpreted as "#ccccaa". Examples with full opacity include "#00ff00" (green), "#000000" (black), "#ffffff" (white) and "#cca" (gray). #00ff0080" is an example of a half-transparent green color.
- Colors through color models. Colors specified using the RGB, RGBA, HSL, HSLA, HSV (HSB) and HSVA (HSBA) color models are recognized. RGB and RGBA color components are given as numbers between 0 and 255 (inclusive) while the parameters for the other color models are given as numbers between 0 and 100 (inclusive), with the exceptions being hues, which have no defined range, and alpha values, which are given as numbers between 0 and 1 (inclusive). Numbers may also be specified as percentages, except for hues. Parentheses are optional, as are commas. Examples include "rgb (255, 0, 0)", "rgb 255 0 0", "rgba (255, 0, 0, .5)", "hsl(0, 100%, 50%)", "hsla(0, 100%, 50%, .5)", "hsl(0, 100%, 50%)", "hsl 0 1.0 0.5", "hsb(0, 100%, 100%)", "hsba(0, 100%, 100%, .5)", "hsv (0 100% 100%)" and "hsv 0 1 1".
Examples
Returns a color corresponding to a deeply saturated red color.
Returns a color corresponding to a deeply saturated red color.
Color.RedColor,Red is identical to
COLOR("RED")COLOR("RED"), but has the added
advantage that typos are flagged immediately instead of only when the app
is run. Writing Color.
, followed by the color name, only
works for named colors, though, whereas the COLOR function also works
with hex notation (COLOR("#00ff00")COLOR("#00ff00")) and with color
models (COLOR("rgb (255, 0,
0)")COLOR("rgb (255, 0,
0)")). Also, the COLOR function is case-insensitive, meaning that
COLOR("RED")COLOR("RED") works, but Color.REDColor,RED does not.
Returns a color corresponding to a pale red color.
Returns a color corresponding to a pale red color. Again, Color.RedA100Color,RedA100 is identical to COLOR("red A100")COLOR("red A100").
Returns a color corresponding to a moderately saturated red color, using the same hex notation that is familiar to many web developers.
Returns a color corresponding to a deeply saturated red color, using notation used by Cascading Style Sheets (CSS), which is familiar to web developers.
Returns an array with the default colors red and blue.
Returns an array with the default colors red and blue. This formula returns the same array as { COLOR("red"), COLOR("blue") }{ COLOR("red"); COLOR("blue") }.
Returns an array with the default colors red and blue. This formula returns the same array as COLOR({ "red", "blue" })COLOR({ "red"; "blue" }).