Create color

Syntax

	color("red")
color("#ff0099")
color(r: 200, g: 60, b: 20, a: 200)
color(h:150, s:30, l:60)

Description

Generates a color value either from a CSS color description or via the components in the red-green-blue or HSL color space.

Parameter

Color name Type Type Description Mandatory Default
css String The CSS color description. no -
r Number The red value (0..255) no 0
g Number The green value (0..255) no 0
b Number The blue value (0..255) no 0
a Number The alpha value (0..255) no 255
h Number The hue angle (0..360) no 0
s Number The saturation (0..100) no 100
l Number The luminance (0..100) no 50
from Color Sample color no -

Return value

Type: Color

The color that corresponds to the specified values. The following rules apply in the specified order:

  • If css is specified, the description is translated into a color. If a is also specified, then this alpha value is applied to the color. All other values are ignored.
  • If either r, g, or b is specified, a color is created in the RGB color space. If a is also specified, then this alpha value is applied to the color. All other values are ignored.
  • A color is created in the HSL color space from the specified values h, s, and l. Missing values are taken from the sample color from if this is specified. Without a sample color, missing values are filled with the specified default values.

Examples

All colors of the rainbow

	count(0, 360, 20).map(h -> color(h: $h, s:80))

Output: List with the colors of the rainbow