Expand description
Paint primitives: the “what do we fill a shape with” side of theming.
A Paint is either a flat Color, a LinearGradient or a
RadialGradient. Gradients carry their colour stops, a direction (angle
for linear, center+radius for radial) and the GradientSpace in which
stops are interpolated. Sampling happens downstream in the renderer; these
types are pure data and have no rendering logic of their own.
§Stop positions
Stops are represented as fractions (0.0..=1.0 for the caller’s mental
model) but the ColorStop::position field accepts values outside
that range. This is intentional: design-tool exports often emit
gradients whose stops fall outside [0, 1], meaning the visible region
of the shape only covers a middle slice of the interpolation. The
renderer is expected to extrapolate linearly, not clamp.
§Colour space
Picking the right interpolation space matters for saturated gradients:
interpolating #04D9FE → #8A38F5 in sRGB produces a muddy grey in the
middle, while Oklab keeps the chroma. The space is resolved at theme-load
time (stops converted once), not per pixel.
Structs§
- One stop of a gradient: a
positionalong the gradient axis (for linear) or along the radius (for radial), plus theColorat that point. - A straight gradient swept along a vector set by an angle.
- A gradient radiating from a centre point out to a radius.
Enums§
- Colour space in which a gradient’s stops are interpolated.
- How a shape is filled: a flat colour or one of the gradient variants.