Colour

The colour vocabulary an author writes and a surface resolves: hues and their tones, the ramps, the surface paints, and the CSS each becomes.

@internote/canvas-sdk42 exports

#Functions

blendedColourCss
packages/canvas-sdk/src/paint/index.ts:246
Converts a colour attribute to CSS, blending from the old colour to the new one while a !cue.to change is under way.
(
    resolved: unknown,
    transition: TrackTransition | null | undefined,
    fallback: string,
): string
blendedToneCss
packages/canvas-sdk/src/paint/index.ts:274
Returns the CSS for one tone of a surface's hue, blending while a !cue.to colour change is under way, or an empty string if the colour has no hue.
(
    resolved: unknown,
    transition: TrackTransition | null | undefined,
    tone: Tone,
): string
colourCss
packages/canvas-sdk/src/paint/colour.ts:490
Converts a colour attribute value such as blue or hex(0064FA) to a CSS colour, or returns fallback if it is not a colour.
(value: unknown, fallback?: string): string
colourToneCss
packages/canvas-sdk/src/paint/colour.ts:221
Converts a colour attribute value to the CSS for its hue at another tone, so blue at light gives var(--blue-pale).
(value: unknown, tone: Tone, fallback?: string): string
colourTypeWith
packages/canvas-sdk/src/paint/colour.ts:179
Builds the compiler's type declaration for a colour attribute, with options to drop tones, accept a list, or add keywords of your own.
({ extra, tones, list, }?: {
    extra?: readonly string[];
    tones?: boolean;
    list?: boolean;
}): TypeSpec
flatOpacity
packages/canvas-sdk/src/paint/index.ts:205
Returns the opacity for position t (0 to 1) along a single-colour surface's range: floor at the low end, fully opaque at the high end.
(t: number, floor?: number): number
flatShare
packages/canvas-sdk/src/paint/index.ts:187
Returns how much a surface should show its range as opacity rather than colour, from 0 (a hue) to 1 (a literal), with values between during a !cue.to change.
(resolved: unknown, transition: TrackTransition | null | undefined): number
hueHover
packages/canvas-sdk/src/paint/index.ts:77
Returns step 2 of a colour's hue as CSS, the hover background for a control tinted with hueTint.
(colour: string | undefined, fallback?: string): string
hueOf
packages/canvas-sdk/src/paint/colour.ts:502
Returns the hue of a colour attribute value without its tone, so dark-blue gives 'blue'.
(value: unknown): Hue | null
hueStep
packages/canvas-sdk/src/paint/index.ts:95
Returns any numbered step (1 to 10) of a colour's hue as CSS.
(colour: string | undefined, step: number, fallback?: string): string
hueStopsOf
packages/canvas-sdk/src/paint/colour.ts:322
Returns the three CSS colours a hue's scale runs through, lightest to darkest, or null if the value is not a hue.
(value: unknown): [string, string, string] | null
hueText
packages/canvas-sdk/src/paint/index.ts:84
Returns step 10 of a colour's hue as CSS, the text colour for a label on a hueTint background.
(colour: string | undefined, fallback?: string): string
hueTint
packages/canvas-sdk/src/paint/index.ts:70
Returns the palest step of a colour's hue as CSS (step 1), the background for a chip or row in that colour.
(colour: string | undefined, fallback?: string): string
hueToneVar
packages/canvas-sdk/src/paint/colour.ts:459
Returns the CSS variable for a hue at a tone: hueToneVar('blue', 'dark') is 'var(--blue-deep)'.
(hue: Hue, tone: Tone): string
parseColour
packages/canvas-sdk/src/paint/colour.ts:409
Parses a colour attribute value such as light-blue or hex(0064FA) into a Colour, or returns null if it is not a colour.
(value: unknown, { tones }?: ColourVocabulary): Colour | null
parseSurfacePaint
packages/canvas-sdk/src/paint/colour.ts:286
Parses a surface-colour value into the colour scale a heatmap or contour draws with, or returns null if it is not a valid colour.
(value: unknown): SurfacePaint | null
rampCss
packages/canvas-sdk/src/paint/index.ts:226
Returns the CSS colour at position t (0 to 1) along a list of colour stops, blending linearly between neighbours.
(stops: readonly string[], t: number): string
rampStopsOf
packages/canvas-sdk/src/paint/index.ts:214
Returns the hex stops for multicolour or temperature, or null for any other value; an empty value counts as multicolour.
(colour: unknown): string[] | null
resolvedColourCss
packages/canvas-sdk/src/paint/colour.ts:471
Converts a parsed Colour to a CSS colour for a fill or stroke.
(colour: Colour): string
surfacePaintAt
packages/canvas-sdk/src/paint/index.ts:154
Returns the fill and opacity a heatmap or contour draws at position t (0 to 1) of its value range, blending across a !cue.to colour change.
(
    resolved: unknown,
    transition: TrackTransition | null | undefined,
    t: number,
    fallback: string,
): {
    fill: string;
    opacity: number;
}
surfacePaintOf
packages/canvas-sdk/src/paint/index.ts:124
Parses a heatmap, contour or choropleth's colour into the scale it draws with, accepting multicolour and temperature as well as colours.
(value: unknown): SurfacePaint | null
writtenColour
packages/canvas-sdk/src/paint/colour.ts:447
Turns a parsed Colour back into the text an author would write, the inverse of parseColour.
(colour: Colour): string

#Constants

COLOUR_NAMES
packages/canvas-sdk/src/paint/colour.ts:112
Every colour name a colour attribute accepts: each hue in its three tones, then neutral.
readonly string[]
colourTypeSpec
packages/canvas-sdk/src/paint/colour.ts:209
The compiler's declaration of the language's colour type: any name in COLOUR_NAMES, or a hex(…) or rgb(…) literal.
TypeSpec
HEX_PATTERN
packages/canvas-sdk/src/paint/colour.ts:144
A regular expression source matching a hex colour as authors write it: hex(0064FA) or hex(fff).
string
HUES
packages/canvas-sdk/src/paint/colour.ts:75
The nine colour names an author can write, such as blue or teal, in the order the editor's swatch picker lists them.
readonly [
    "blue",
    "red",
    "orange",
    "yellow",
    "teal",
    "green",
    "pink",
    "purple",
    "grey"
]
NEUTRAL
packages/canvas-sdk/src/paint/colour.ts:102
The colour name neutral, which paints a mark in the same colour as body text.
string
RAINBOW_STOPS
packages/canvas-sdk/src/paint/index.ts:113
The hex colours of the multicolour scale for heatmaps and contours, violet for low values through to red for high.
string[]
RAMP_NAMES
packages/canvas-sdk/src/paint/index.ts:211
The two named colour scales surface-colour accepts on top of ordinary colours.
readonly ["multicolour", "temperature"]
RGB_PATTERN
packages/canvas-sdk/src/paint/colour.ts:155
A regular expression source matching an RGB colour as authors write it: rgb(123, 42, 23).
string
SURFACE_NAMES
packages/canvas-sdk/src/paint/colour.ts:134
The colour names a heatmap, contour or other value-mapped surface accepts: the nine plain hues, with no tones and no neutral.
readonly string[]
TEMPERATURE_STOPS
packages/canvas-sdk/src/paint/index.ts:115
The hex colours of the temperature scale for heatmaps and contours: dark blue → light blue → white → light red → dark red.
string[]
TONE_PREFIXES
packages/canvas-sdk/src/paint/colour.ts:93
The prefixes an author puts before a hue to pick a shade, as in light-blue and dark-blue.
readonly ["light", "dark"]
TONES
packages/canvas-sdk/src/paint/colour.ts:87
The three shades a hue comes in: light, base and dark.
readonly ["light", "base", "dark"]

#Interfaces

ColourVocabulary
packages/canvas-sdk/src/paint/colour.ts:340
Options for parseColour: whether to accept every colour name, or only those a value-mapped surface allows.
tones
Whether light-/dark- names and neutral are admitted. False is the surface vocabulary: neutral goes with the tones, naming one token rather than a scale.
boolean
HueColour
packages/canvas-sdk/src/paint/colour.ts:350
A parsed named colour such as blue, light-blue or dark-blue.
hueRequired
The colour name without its tone prefix: 'blue' for light-blue.
blueredorangeyellowtealgreenpinkpurplegrey
kindRequired
Always 'hue'; tells the three Colour forms apart.
'hue'
toneRequired
The shade: 'light', 'dark', or 'base' when there was no prefix.
lightbasedark
LiteralColour
packages/canvas-sdk/src/paint/colour.ts:366
A parsed hex(…) or rgb(…) colour, which is drawn exactly as written in both themes.
cssRequired
The colour as CSS: hex(0064FA) becomes '#0064fa', rgb(1,2,3) becomes 'rgb(1, 2, 3)'.
string
kindRequired
Always 'literal'; tells the three Colour forms apart.
'literal'
NeutralColour
packages/canvas-sdk/src/paint/colour.ts:360
The parsed colour neutral, the body-text colour.
kindRequired
Always 'neutral'; tells the three Colour forms apart.
'neutral'
SurfacePaint
packages/canvas-sdk/src/paint/colour.ts:254
The colour scale a heatmap or contour draws with, as returned by parseSurfacePaint.
flatRequired
True when there is only one colour and no range to show, as with a hex(…). The surface then shows value as opacity instead: faint at the low end, solid at the high end.
boolean
stopsRequired
CSS colours from the lowest value to the highest; the surface blends between neighbours.
string[]

#Types

Colour
packages/canvas-sdk/src/paint/colour.ts:388
A colour attribute value after parsing: a named hue at a tone, neutral, or a literal hex or RGB colour.
HueColour | NeutralColour | LiteralColour
```ts
parseColour('light-blue'); // { kind: 'hue', hue: 'blue', tone: 'light' }
parseColour('neutral');    // { kind: 'neutral' }
parseColour('hex(0064FA)'); // { kind: 'literal', css: '#0064fa' }
```
Hue
packages/canvas-sdk/src/paint/colour.ts:78
A colour name from HUES, such as 'blue'.
blueredorangeyellowtealgreenpinkpurplegrey
Tone
packages/canvas-sdk/src/paint/colour.ts:90
A shade from TONES: 'light', 'base' or 'dark'.
lightbasedark

Last updated