Skip to main content

Module color

Module color 

Source
Expand description

CSS color conversion helpers for HTML drawables.

These functions turn Cotis color types into CSS color strings used by drawable_defaults (background-color, color, etc.).

§Default vs feature-gated API

Without features, all helpers take Color.

With complex_color, fill/background helpers take ColorLayer. With complex_colored_text, text_color_css takes ColorLayer.

§Gradients

When features are enabled, only ColorLayer::Solid produces a real CSS color. Other layer variants (linear, radial, layered) currently return "transparent". Full CSS gradient mapping is on the roadmap.

Functions§

color_css
Formats a Cotis Color as a CSS rgba(r, g, b, a) string.
css_alpha
Normalizes alpha to the 0.0–1.0 range expected by CSS rgba().
custom_background_css
CSS background color for custom HTML host elements.
image_background_css
CSS background color behind an Image drawable.
rectangle_fill_css
CSS background-color (or fill) for a Rectangle.
text_color_css
CSS color for a Text drawable.