Color Channel Functions
Example:
#
hueExtracts the hue channel of a color object in the HSL color space.
Parameters: color
- a color object.
Returns: integer
0-360
Example: hue(hsl(90, 100%, 50%))
Output: 90
#
saturationExtracts the saturation channel of a color object in the HSL color space.
Parameters: color
- a color object.
Returns: percentage
0-100
Example: saturation(hsl(90, 100%, 50%))
Output: 100%
#
lightnessExtracts the lightness channel of a color object in the HSL color space.
Parameters: color
- a color object.
Returns: percentage
0-100
Example: lightness(hsl(90, 100%, 50%))
Output: 50%
#
hsvhueExtracts the hue channel of a color object in the HSV color space.
Parameters: color
- a color object.
Returns: integer
0-360
Example: hsvhue(hsv(90, 100%, 50%))
Output: 90
#
hsvsaturationExtracts the saturation channel of a color object in the HSV color space.
Parameters: color
- a color object.
Returns: percentage
0-100
Example: hsvsaturation(hsv(90, 100%, 50%))
Output: 100%
#
hsvvalueExtracts the value channel of a color object in the HSV color space.
Parameters: color
- a color object.
Returns: percentage
0-100
Example: hsvvalue(hsv(90, 100%, 50%))
Output: 50%
#
redExtracts the red channel of a color object.
Parameters: color
- a color object.
Returns: float
0-255
Example: red(rgb(10, 20, 30))
Output: 10
#
greenExtracts the green channel of a color object.
Parameters: color
- a color object.
Returns: float
0-255
Example: green(rgb(10, 20, 30))
Output: 20
#
blueExtracts the blue channel of a color object.
Parameters: color
- a color object.
Returns: float
0-255
Example: blue(rgb(10, 20, 30))
Output: 30
#
alphaExtracts the alpha channel of a color object.
Parameters: color
- a color object.
Returns: float
0-1
Example: alpha(rgba(10, 20, 30, 0.5))
Output: 0.5
#
lumaCalculates the luma (perceptual brightness) of a color object.
Uses SMPTE C / Rec. 709 coefficients, as recommended in WCAG 2.0. This calculation is also used in the contrast function.
Parameters: color
- a color object.
Returns: percentage
0-100%
Example: luma(rgb(100, 200, 30))
Output: 44%
#
luminanceCalculates the value of the luma without gamma correction
Parameters: color
- a color object.
Returns: percentage
0-100%
Example: luminance(rgb(100, 200, 30))
Output: 65%