Expand description
Paths: what a path node draws (docs/adr/0040-a-path-is-a-mask-in-the-atlas.md).
A path is a list of PathOps — SVG’s d with every coordinate
absolute and H, V, S, T and the relative forms expanded by
Path::parse, the one parser every binding goes through — filled by
a rule and, optionally, stroked. The core flattens it once per frame
for the hit outline, rasterizes it through zeno (swash’s rasterizer,
already in the tree for glyphs) into an alpha mask at the node’s
physical scale, keeps the mask in the glyph atlas keyed on a hash of
the ops, and draws it as a GlyphMask quad tinted by the fill or the
stroke colour. The ops live in a per-frame list beside the tree, as a
line’s points do, and a node refers to its run by PathId.
Structs§
- Path
- A path as an app builds one: the ops, the fill rule, and an optional
stroke. The fill colour is the node’s
bg; the stroke’s width and colour are thecrate::line::Stroke’s (curveis ignored). - Path
Error - Where a
dstring went wrong: the byte offset and what was expected. - PathId
- Index into the frame’s path list.
- Path
Store - The frame’s paths, and the previous frame’s while an
exitneeds it. - Path
Texture - A mask drawn from a texture of its own rather than the atlas (ADR 0040, decisions 7 and 8): the handle the backend caches it under, and the pixels it uploads from.
- Path
Textures - The texture-backed masks of one core, by the mask key the atlas would have held them under. One a frame does not draw is dropped at the next frame’s start, its handle handed to the display list for the backend to free; an animating path, whose key is new each frame, thus uploads one texture a frame and frees one. The ones a core still holds when it goes go the way a removed image does: to the session, for the next display list any of its windows builds (RG112).
- Turn
- A path’s turn (
docs/adr/0041-a-mask-turns-about-its-centre.md): how far it is turned, in turns — clockwise with y down, asPath::sectorcounts them — and the point it turns about, in the path’s own coordinates;Noneis the centre of the outline’s box. A path with a turn is boxed by the square the turn sweeps, so its mask is one mask at every angle and the quad that draws it carries the angle.
Enums§
- Fill
Rule - How a path’s inside is decided: SVG’s default, or the polygon’s rule.
- Mask
Paint - What one mask paints: the fill by its rule, bled half a pixel so two
fills sharing an edge meet without the background showing, or the
outline stroked
widthphysical px wide — whole, or cut into the marks of a dash pattern (backlog V2), its lengths physical too. - PathOp
- One drawing command, every coordinate absolute, in the space the path was declared in.
Constants§
- ANIMATING_
WINDOW - How many frames apart two changes of one key’s ops may be and still be an animation: a shape driven at a quarter of the frame rate, or one whose changes have a frame between them that something else asked for, moves as surely as one that changes every frame, and each of its shapes would be a slot the atlas never reuses.
- CONTOUR_
BREAK - Separates two contours in a flattened outline: a point that is not a
point.
in_pathreads it as the end of one closed contour and the start of the next. - FLATTEN_
TOLERANCE - How far a flattened curve may stray from the true one, logical px. The hit outline’s tolerance; the rasterizer flattens on its own.
- MAX_
ATLAS_ MASK_ TEXELS - The texels a mask may take of the atlas before it goes to a texture of its own: a quarter of the biggest page, since four of them would empty it every frame.
- MAX_
MASK_ SIDE - The widest or tallest a mask may be and still be drawn from a texture
of its own: a texture every device kui runs on can hold —
kui-wgpuopens its device with wgpu’s default limits, whosemax_texture_dimension_2dis this number whatever the adapter could do, so the core’s limit and the renderer’s are one. Past it the node draws nothing, withpath-too-large. A host that draws the list itself on a device that holds less refuses the texture on its side. - OP_ARC
- OP_
CLOSE - OP_
CUBIC - OP_LINE
- OP_MOVE
- The op codes of the flat wire form: a code, then its operands.
- OP_QUAD
- SETTLED_
AFTER - How many frames an animating key’s shape stays the same before it is a still shape again, and its mask the atlas’s: a second at 120 Hz. A spinner that pauses for a frame or ten stays out; one that stopped stops costing a texture and a draw of its own.
Functions§
- bounds
- The bounding box of a flattened outline, ignoring contour breaks;
Nonefor no points. - flatten
- Flattens
opsinto closed contours inout, each contour’s points followed byCONTOUR_BREAK. Every subpath is closed for the purpose of a fill, as SVG closes it. A move with nothing after it adds nothing. - flatten_
stroke - Flattens
opsinto the polylines a stroke draws, each followed byCONTOUR_BREAK: a subpath itsZclosed ends back on its start, an open one ends where it was left, so a stroke’s hit pieces are the pieces it paints and no chord across an open curve is among them. - hash_
ops - FNV-1a over the ops’ bits: what a mask is keyed on. The same ops are the same hash in every binding, since the floats crossed as floats.
- in_path
- Whether
pis inside the flattened contourspts(asflattenlays them out) byrule. A point on an edge counts as inside on one side and outside on the other, so of two wedges sharing an edge exactly one takes it. - rasterize
- Rasterizes
ops(in logical px, relative to the node’s box) into aw × halpha mask atscale, the node’s box shifted bybinquarter-pixels so a node at a fractional position lands on the pixel grid as it would be drawn.w * hbytes, row after row. - rasterize_
at rasterizewith the box’s originoffphysical px into the mask: what a turning path’s mask is drawn with, its pivot at the mask’s centre.- turned
pturned byangleradians (clockwise, y down) aboutc.
Type Aliases§
- DashCut
- A dash pattern as the rasterizer takes it: the centre-line lengths of
a mark, a gap, a mark and a gap, and how far into them the stroke
starts.
crate::line::Dashis what an app declares.