The color string (e.g. "#ff0000", "rgb(255,0,0)").
Creates a new Color instance from RGB values.
Red component (0-255).
Green component (0-255).
Blue component (0-255).
Optionala: number
Alpha component (0-1).
Gets the contrast ratio between the color and another one, as WCAG defines it.
The other color.
The ratio (1 for the same luminance, 21 for black and white).
Darkens the color by a given percentage.
The percentage to darken (0-100).
The current Color instance.
Gets the alpha (transparency) value of the color.
The alpha value (0-1).
Checks if the color is invalid (e.g. failed parsing).
True if the color is invalid, false otherwise.
Lightens the color by a given percentage.
The percentage to lighten (0-100).
The current Color instance.
Gets the relative luminance of the color, as WCAG defines it. The alpha is not used.
The luminance (0 for black, 1 for white).
Mixes the color with another one, alpha included.
The other color.
The part of the other color (0-1): 0 keeps this color, 1 gives the other one.
The current Color instance.
Sets the alpha (transparency) value of the color.
The new alpha value (0-1).
The current Color instance.
Sets the color using HSV (Hue, Saturation, Value) components.
Hue (0-1).
Saturation (0-1).
Value (0-1).
Alpha (0-1, default 1.0).
The current Color instance.
Sets the color using RGB (Red, Green, Blue) components.
Red component (0-255).
Green component (0-255).
Blue component (0-255).
Alpha component (0-1, default 1.0).
The current Color instance.
accepts: #aaa #ababab #ababab55 rgb(a,b,c) rgba(a,b,c,d) var( --color-5 ) cyan transparent any other colour of css the browser knows: hsl( ), oklch( ), color-mix( )...
Returns the Hex string representation of the color.
The hex color string (e.g. "#ff0000" or "#ff000080").
Converts the color to HSV representation.
An object containing hue, saturation, value, and alpha properties.
return the number value of the color (no transparency)
Returns the color as an RGB object.
An object containing red, green, blue, and alpha properties.
Returns the CSS string representation of the color.
false (default): never the alpha; true: the alpha when the color is not opaque.
The CSS color string (e.g. "rgb(255,0,0)" or "rgba(255,0,0,0.500)").
Creates a new Color instance from a string.