Crate cssparser_color

Source
Expand description

Fairly complete css-color implementation. Relative colors, color-mix, system colors, and other such things require better calc() support and integration.

Structs§

ColorFunction
A color specified by the color() function. https://drafts.csswg.org/css-color-4/#color-function
DefaultColorParser
Default implementation of a ColorParser
Hsl
Color specified by hue, saturation and lightness components.
Hwb
Color specified by hue, whiteness and blackness components.
Lab
Color specified by lightness, a- and b-axis components.
Lch
Color specified by lightness, chroma and hue components.
Oklab
Color specified by lightness, a- and b-axis components.
Oklch
Color specified by lightness, chroma and hue components.
RgbaLegacy
A color with red, green, blue, and alpha components, in a byte each.

Enums§

AngleOrNumber
Either an angle or a number.
Color
Describes one of the value values according to the CSS specification.
NumberOrPercentage
Either a number or a percentage.

Traits§

ColorParser
A trait that can be used to hook into how cssparser parses color components, with the intention of implementing more complicated behavior.
FromParsedColor
This trait is used by the ColorParser to construct colors of any type.

Functions§

hsl_to_rgb
https://drafts.csswg.org/css-color/#hsl-color except with h pre-multiplied by 3, to avoid some rounding errors.
hwb_to_rgb
https://drafts.csswg.org/css-color-4/#hwb-to-rgb
parse_color_keyword
Return the named color with the given name.
parse_color_with
Parse a CSS color using the specified ColorParser and return a new color value on success.
parse_components
Parse the color components and alpha with the modern [color-4] syntax.