Color

Color :: # (opaque)

A validated CSS color. RGB channels and alpha use bytes in the range 0–255.

is_eq : _

Compare stored CSS spellings; different spellings may render the same color.

rgb : { red : U8, green : U8, blue : U8 } -> Color

Construct an opaque RGB color.

rgba : { red : U8, green : U8, blue : U8, alpha : U8 } -> Color

Alpha 0 is transparent and 255 is opaque.

hex : Str -> Try(Color, [InvalidHex(Str)])

Parse exactly six hexadecimal digits preceded by #. Both letter cases are accepted and preserved. Short forms and alpha suffixes are rejected as InvalidHex(original_text).

named : Str -> Try(Color, [UnknownColor(Str)])

Parse a supported CSS named color, independent of ASCII case. The stored spelling is lowercase. Unknown names return UnknownColor(original_text). Use Color.rgba when transparency is needed.

to_css : Color -> Str

Read the CSS value for use in a stylesheet or Plotly field.

to_json_value : Color -> InternalJson

Internal composition hook used by Plume's renderers. Applications normally use Color.to_json for complete JSON text; this returns the package's safe internal value without accepting raw JSON.

to_json : Color -> Str

Serialize this validated value as a complete JSON document.