Module color

Module color 

Source
Expand description

This module provides color parsing and manipulation strictly following the CSS Color Module Level 4 specification.

Unlike SASS, which sometimes deviates or extends CSS behaviors, this module implements color functions and parsing rules in accordance with the standard CSS spec, ensuring predictable and interoperable color handling for web-oriented applications.

§Overview

  • Color struct: Represents an RGBA color with optional transparency.
  • Named colors: Predefined according to the CSS spec (e.g., "red", "blue").
  • CSS-like parsing: Supports hex codes, rgb()/hsl()/hwb() notations, etc.
  • Color transformations: grayscale(), lighten(), darken(), etc. (modeled after CSS, not SASS).

§Examples

use grimoire_css_color_toolkit_lib::Color;
let c = Color::try_from_str("rgb(255, 0, 0)").unwrap(); // strictly CSS parsing

Structs§

Color
A color in RGBA form, optionally with an alpha channel.