Expand description
Gradients: what a box’s gradient row paints
(docs/adr/0042-a-gradient-is-an-image-the-core-paints.md).
A gradient is a shape — a direction, or a centre — and two or more
stops, defined on the box’s unit square and stretched to the box.
The core rasterizes it once into a small RGBA image in the atlas, keyed
by what it is and not by where it is drawn, and the box paints it with
one Image quad: a strip for a gradient along an axis, a square for
any other. So a renderer that draws an image draws a gradient, and a
box that resizes, or a thousand boxes that share one, rasterize
nothing.
use kui_core::{Color, Gradient, Side};
let g = Gradient::to(Side::Bottom, [Color::hex(0x1e2030ff), Color::hex(0x14161eff)]);
assert_eq!(g.raster_size(), (1, 256));Structs§
- Gradient
- A box’s gradient: see the module’s notes. Built by
Gradient::to,Gradient::angleorGradient::radial, or read from plain data byparse_with. - Stop
- One stop: a colour, and where along the gradient it sits, 0 to 1. A stop with no position is spaced evenly between its neighbours that have one, the first defaulting to 0 and the last to 1, as CSS spaces them.
Enums§
- Side
- Where a linear gradient runs to: a side or a corner of the box.
Constants§
- SQUARE
- Texels on a side of the square every other gradient is drawn into.
- STRIP
- Texels along a strip, for a gradient along an axis.
Functions§
- parse
parse_withwith no token lookup: a$nameis an error.- parse_
with - Reads a gradient from plain data, the form every binding carries: