Expand description
CPU mirror of the signed-distance functions in shaders/shape.wgsl.
The software (pixels) renderer rasterizes the same shapes as the GPU. Both evaluate these formulas, so a stroked rect or an arc looks the same on either backend instead of the CPU path quietly degrading to a filled box.
Angle convention (shared with cranpose_ui_graphics::stroke): radians, 0
along +X, increasing clockwise on screen (y-down device space).
Functions§
- arc_
coverage - Coverage of
pointby an arc band. - coverage_
for_ distance - Antialiased coverage for a signed distance, matching the shader’s
1.0 - smoothstep(-0.5, 0.5, d). - sdf_
arc_ band - Signed distance to a circular band limited to an angular sweep — the shape behind both stroked arcs and filled annular sectors.
- sdf_
rounded_ rect - Signed distance to a rounded box centered at the origin.
- sdf_
stroked_ rounded_ rect - Signed distance to the outline of a rounded box stroked with a centered
stroke of width
2 * half_width. - stroked_
rect_ coverage - Coverage of
pointby a stroked rect/round-rect whose (already inflated) bounds arerect.