Expand description
Vector shapes and recorded drawings -> RGBA layers (CPU rasteriser; the GPU path samples the result).
render(style, scale, local_t) draws the shape centred in its own tight layer:
- Rect / Ellipse / Triangle / Polygon / Star:
fillplus an optionalstrokeoutline ofstroke_width(project px x scale); rounded corners for Rect viacorner. - Line / Arrow: from (-w, -h) to (+w, +h) in layer space, head sized by
corner. - Draw: the recorded strokes revealed up to
local_t * draw_rate(0 = all at once) on the optionalpagebackground. Anti-aliased with a coverage rasteriser (no new deps). Cached byShapeStyle::cache_key()+ size + reveal bucket.
StructsΒ§
- Edge π
- A non-horizontal edge, top to bottom.
- Path π
pts[ends[i-1]..ends[i]]is one closed subpath, all wound the same way so a nonzero fill unions overlapping pieces instead of cancelling them.- Shape
Rasterizer
ConstantsΒ§
- CACHE_
MAX π - MAX_DIM π
- Layer dimensions are clamped to this;
scaleshrinks instead so the geometry stays consistent. - MAX_
PIXELS π - β¦and so is the total pixel count (64 MB RGBA), which a 4K full-canvas shape stays well under.
- REVEAL_
HZ π - Reveal-time quantisation for the cache (a drawing re-rasterises 30x/s at most).
- STAR_
INNER π - Star inner radius as a fraction of the outer one.
- SUB π
- Vertical sub-scanlines per pixel row (horizontal coverage is exact, so 4 is plenty).
FunctionsΒ§
- add_
disc π - add_
span π - add_
stroke π - Thick polyline in layer px: one quad per segment plus a disc at every vertex (round caps/joins).
- arc_
steps π - Segments per quarter turn for a curve of pixel radius
r_px(sagitta stays well under a pixel). - arrow_
head π - Arrow head length in project px (
corner, or a stroke-relative default when it is 0). - blend π
- Source-over in straight (non-premultiplied) alpha.
- bucket_
time π - draw_
half_ πsize - Half-size of a drawing: the strokes are relative to the layer centre, so the layer is symmetric.
- fill_
path π - Scanline fill with 4x vertical sub-sampling and exact horizontal coverage. Writes
cov(zeroing only the band it touches) and returns that band as (x0, y0, x1, y1). - half_
size π - ngon π
- Regular polygon (or star: 2x the vertices, alternating radii) inscribed in the w x h ellipse, first vertex pointing up.
- reveal_
bucket π - Reveal bucket for the cache key: 0 = not a drawing,
u32::MAX= fully revealed. - revealed π
- Points of a stroke revealed at
revealseconds (the last segment is cut proportionally). - shape_
outline π - Closed outline of a filled shape in project px, centred at the origin.
sonly sets how finely curves are subdivided (so a big shape at a big scale stays smooth). - signed_
half π - Half-extents WITH their sign, for the shapes whose extents encode a direction. Line and Arrow run
from (-w, -h) to (+w, +h), so making them absolute (as
half_sizemust, for a layer size) collapses every line onto the same diagonal whichever way it was actually drawn. - to_
layer π