color
cheatah-plot v0.1.0-alpha — Biome Standard 0.6.3-alpha
Classes
Color— One RGBA colour, channels in [0, 1].
Functions
An opaque colour from red/green/blue channels.
r | red in [0, 1]. |
g | green in [0, 1]. |
b | blue in [0, 1]. |
the opaque Color (alpha 1).
O(1).
the Color.
systests/test_color.purrimport 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 colourColor 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).
r | red in [0, 1]. |
g | green in [0, 1]. |
b | blue in [0, 1]. |
a | alpha in [0, 1]. |
the Color.
O(1).
the Color.
systests/test_color.purrimport 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 fillsThe "auto" colour sentinel: alpha 0.
A Series carrying it gets the next palette colour when the figure resolves styles.
the transparent auto sentinel.
O(1).
the Color.
systests/test_color.purrimport plot.color as color
let c = color.auto_color()
let a = color.is_auto(c) # -> true: the figure will assign the next palette colourWhether c is the auto sentinel (alpha exactly 0) — the test the figure layer runs before assigning palette colours.
c | the colour to inspect. |
true when c means "auto".
O(1).
none.
systests/test_color.purrimport plot.color as color
let c = color.named("tomato")
let a = color.is_auto(c) # -> false: an explicit colour is kept as-isLinear interpolation between two colours, channel-wise (alpha included), with t clamped to [0, 1] — the primitive every colormap is built from.
c0 | the colour at t = 0. |
c1 | the colour at t = 1. |
t | the blend position (clamped to [0, 1]). |
the blended Color.
O(1).
the Color.
systests/test_color.purrimport 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)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.
anchors | the colour stops, evenly spaced across [0, 1]. |
t | the sample position (clamped to [0, 1]). |
the interpolated Color.
O(1).
the Color.
systests/test_color.purrimport 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 stopsThe viridis colormap (dark violet -> teal -> yellow), sampled at t — perceptually uniform and colour-blind friendly; the default for continuous data.
t | the sample position in [0, 1] (clamped). |
the Color at t.
O(1).
the Color (plus the transient anchor table).
systests/test_color.purrimport plot.color as color
let lo = color.viridis(0.0) # -> dark violet
let hi = color.viridis(1.0) # -> bright yellowThe magma colormap (black -> purple -> orange -> pale yellow), sampled at t.
The coolwarm diverging colormap (blue -> pale grey -> red), sampled at t — for data with a meaningful midpoint (deviations, correlations).
t | the sample position in [0, 1] (clamped). |
the Color at t.
O(1).
the Color (plus the transient anchor table).
systests/test_color.purrimport plot.color as color
let below = color.coolwarm(0.0) # -> blue: under the midpoint
let mid = color.coolwarm(0.5) # -> pale grey: the meaningful middleThe 10-colour categorical palette series colours cycle through (the familiar matplotlib-style tab10 wheel: blue, orange, green, red, violet, brown, pink, grey, olive, cyan).
the 10 opaque categorical colours, in cycling order.
O(1).
the returned list.
systests/test_color.purrimport plot.color as color
let wheel = color.tab10()
let second = wheel[1] # -> the tab10 orange (series index 1)A categorical palette by name: "tab10" (default) or "dark" (tab10 darkened for light backgrounds).
Unknown names return tab10 — a plot always gets usable colours.
name | the palette name. |
the palette colours, in cycling order.
O(1).
the returned list.
systests/test_color.purrimport plot.color as color
let dark = color.palette("dark")
let first = dark[0] # -> tab10 blue, darkened for light backgroundsA 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.
name | the colour name (lowercase). |
the named Color (opaque black when unknown).
O(1).
the Color.
systests/test_color.purrimport plot.color as color
let stroke = color.named("crimson")
let accent = color.named("gold") # -> everyday colours for the _styled marksABI/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.
the module name ("color").
