package color
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Color
Source
This module deals with colors.
Classic RedGreenBlue (& optional alpha) representation, closely matching the way screens display colors.
Hue, Saturation, Lightness. More intuitive to work with than Rgb
.
A color space that is ok. See the author's blog for more info.
The polar version of Oklab
. See mozilla's page on it for more info. Arguably the easiest space to work with, as it closely match our perception of colors.
Parse a hexadecimal color code. Handles short format like #rgb
or long format #rrggbb
. Short format #abc
corresponds to long format #aabbcc
.
Converts a color to its hexadecimal representation. The alpha channel is not represented.
Darkens a color by subtracting an amount to the lightness channel
The perceived lightness of any color, with 0. for the darkest black and 1. for the lightest white.
Contrast ratio between two colors. It is a value that can range from 1. to 21. https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef W3 reference
}
Checks if text of one color is readable on a background of the second color. A minimum contrast ratio of 4.5 is recommended to ensure that text is readable on a given background. W3 reference
Returns a readable foreground text color (picks between black or white) for a given background color