cheatah
Module

color

cheatah-plot v0.1.0-alpha — Biome Standard 0.6.3-alpha

Classes

Functions

fn std::ostream & operator<<(std::ostream &os_, const Color &v_) #
fn Color rgb(builtins::Value auto &&r, builtins::Value auto &&g, builtins::Value auto &&b) #

An opaque colour from red/green/blue channels.

Parameters
r

red in [0, 1].

g

green in [0, 1].

b

blue in [0, 1].

Returns

the opaque Color (alpha 1).

Complexity

O(1).

Allocation

the Color.

System testsystests/test_color.purr
Example
import plot.color as color
let steel = color.rgb(0.275, 0.510, 0.706)
let a = steel.a   # -> 1.0: rgb always builds an opaque colour
fn Color rgba(builtins::Value auto &&r, builtins::Value auto &&g, builtins::Value auto &&b, builtins::Value auto &&a) #

A colour from all four channels.

Note alpha exactly 0 is reserved as the auto sentinel — a fully transparent DRAWN colour is not representable (use a tiny alpha instead; nothing visible changes).

Parameters
r

red in [0, 1].

g

green in [0, 1].

b

blue in [0, 1].

a

alpha in [0, 1].

Returns

the Color.

Complexity

O(1).

Allocation

the Color.

System testsystests/test_color.purr
Example
import plot.color as color
let band = color.rgba(0.122, 0.467, 0.706, 0.25)
let a = band.a   # -> 0.25: a translucent blue for bands and fills
fn Color auto_color() #

The "auto" colour sentinel: alpha 0.

A Series carrying it gets the next palette colour when the figure resolves styles.

Returns

the transparent auto sentinel.

Complexity

O(1).

Allocation

the Color.

System testsystests/test_color.purr
Example
import plot.color as color
let c = color.auto_color()
let a = color.is_auto(c)   # -> true: the figure will assign the next palette colour
fn bool is_auto(builtins::Value auto &&c) #

Whether c is the auto sentinel (alpha exactly 0) — the test the figure layer runs before assigning palette colours.

Parameters
c

the colour to inspect.

Returns

true when c means "auto".

Complexity

O(1).

Allocation

none.

System testsystests/test_color.purr
Example
import plot.color as color
let c = color.named("tomato")
let a = color.is_auto(c)   # -> false: an explicit colour is kept as-is
fn Color lerp(builtins::Value auto &&c0, builtins::Value auto &&c1, builtins::Value auto &&t) #

Linear interpolation between two colours, channel-wise (alpha included), with t clamped to [0, 1] — the primitive every colormap is built from.

Parameters
c0

the colour at t = 0.

c1

the colour at t = 1.

t

the blend position (clamped to [0, 1]).

Returns

the blended Color.

Complexity

O(1).

Allocation

the Color.

System testsystests/test_color.purr
Example
import plot.color as color
let blue = color.rgb(0.0, 0.0, 1.0)
let red = color.rgb(1.0, 0.0, 0.0)
let mid = color.lerp(blue, red, 0.5)   # -> the even blend (r 0.5, b 0.5)
fn Color sample(builtins::Value auto &&anchors, builtins::Value auto &&t) #

Sample an anchor table at t in [0, 1]: the anchors are treated as evenly spaced stops and the two neighbours of t are blended.

Out-of-range t clamps; an empty table returns opaque black.

Parameters
anchors

the colour stops, evenly spaced across [0, 1].

t

the sample position (clamped to [0, 1]).

Returns

the interpolated Color.

Complexity

O(1).

Allocation

the Color.

System testsystests/test_color.purr
Example
import plot.color as color
import Color from plot.color
let anchors : list<Color> = []
anchors.append(color.rgb(0.0, 0.0, 0.5))
anchors.append(color.rgb(1.0, 1.0, 0.0))
let mid = color.sample(anchors, 0.5)   # -> halfway between the two stops
fn Color viridis(builtins::Value auto &&t) #

The viridis colormap (dark violet -> teal -> yellow), sampled at t — perceptually uniform and colour-blind friendly; the default for continuous data.

Parameters
t

the sample position in [0, 1] (clamped).

Returns

the Color at t.

Complexity

O(1).

Allocation

the Color (plus the transient anchor table).

System testsystests/test_color.purr
Example
import plot.color as color
let lo = color.viridis(0.0)   # -> dark violet
let hi = color.viridis(1.0)   # -> bright yellow
fn Color magma(builtins::Value auto &&t) #

The magma colormap (black -> purple -> orange -> pale yellow), sampled at t.

Parameters
t

the sample position in [0, 1] (clamped).

Returns

the Color at t.

Complexity

O(1).

Allocation

the Color (plus the transient anchor table).

System testsystests/test_color.purr
Example
import plot.color as color
let lo = color.magma(0.0)    # -> near black
let hi = color.magma(0.75)   # -> warm orange
fn Color coolwarm(builtins::Value auto &&t) #

The coolwarm diverging colormap (blue -> pale grey -> red), sampled at t — for data with a meaningful midpoint (deviations, correlations).

Parameters
t

the sample position in [0, 1] (clamped).

Returns

the Color at t.

Complexity

O(1).

Allocation

the Color (plus the transient anchor table).

System testsystests/test_color.purr
Example
import plot.color as color
let below = color.coolwarm(0.0)   # -> blue: under the midpoint
let mid = color.coolwarm(0.5)     # -> pale grey: the meaningful middle
fn std::vector< Color > tab10() #

The 10-colour categorical palette series colours cycle through (the familiar matplotlib-style tab10 wheel: blue, orange, green, red, violet, brown, pink, grey, olive, cyan).

Returns

the 10 opaque categorical colours, in cycling order.

Complexity

O(1).

Allocation

the returned list.

System testsystests/test_color.purr
Example
import plot.color as color
let wheel = color.tab10()
let second = wheel[1]   # -> the tab10 orange (series index 1)
fn std::vector< Color > palette(builtins::Value auto &&name) #

A categorical palette by name: "tab10" (default) or "dark" (tab10 darkened for light backgrounds).

Unknown names return tab10 — a plot always gets usable colours.

Parameters
name

the palette name.

Returns

the palette colours, in cycling order.

Complexity

O(1).

Allocation

the returned list.

System testsystests/test_color.purr
Example
import plot.color as color
let dark = color.palette("dark")
let first = dark[0]   # -> tab10 blue, darkened for light backgrounds
fn Color named(builtins::Value auto &&name) #

A colour from a small CSS-style name table (the everyday names: black, white, red, green, blue, orange, purple, brown, pink, gray, cyan, magenta, gold, teal, steelblue, crimson, forestgreen, darkorange, royalblue, tomato, slategray).

Unknown names return opaque black.

Parameters
name

the colour name (lowercase).

Returns

the named Color (opaque black when unknown).

Complexity

O(1).

Allocation

the Color.

System testsystests/test_color.purr
Example
import plot.color as color
let stroke = color.named("crimson")
let accent = color.named("gold")   # -> everyday colours for the _styled marks
fn const char * module_abi() noexcept #

ABI/identity marker for the color cheatah module: returns the module name.

Auto-emitted by purrc's library emitter. It is the concrete symbol that anchors the module's signed static archive in opaque (source-hidden) builds.

Returns

the module name ("color").