Skip to main content

Crate alpha2_geometry

Crate alpha2_geometry 

Source
Expand description

Deterministic vector geometry for alpha2 shapes.

A shape content tree evaluated at one time (EvaluatedItem) becomes a VectorScene of fills and stroke outlines in device pixels, in drawing order, with their group layers. raster::rasterize turns a path into tile coverage, and queries (bounds, hit tests, lengths, trims) share the same code.

Results are bit-identical on every target: geometry is f64, trigonometry uses libm, arc lengths and flattening use only + - * / and sqrt, and coverage accumulates in scalar f32 in a fixed order. If another crate enables kurbo’s std, stroke outlines and scene keys may differ in the last bits, so shared hash goldens compare coverage only.

Re-exports§

pub use kurbo;

Modules§

affine
Affine transforms and lengths built from libm and sqrt, bit-identical on every target.
arclen
Arc lengths of path segments, from + - * / and sqrt alone.
query
Shape queries (bounds, hit tests, lengths, trimming, resampling, conversion) built on the renderer’s own geometry code.
raster
Path coverage in 16 by 16 tiles: per pixel, the average winding number over its area, mapped by the fill rule.
shapes
Parametric shapes as Bezier paths in pixel space, with the start points and directions After Effects and Lottie use so trims cut them in the same places.
spatial
Motion along spatial curves. A position keyframed with tangents travels along the cubic between keyframes by arc length, at the speed its timing curve sets.
trim
Trim paths: keeping a span of geometry’s length.

Structs§

CanvasSize
The canvas size in device pixels. Normalized (1, 1) maps to (width, height), and normalized lengths are fractions of the shorter side.
EvaluatedPath
A path evaluated at one time.
EvaluatedSubpath
A subpath evaluated at one time.
EvaluatedTransform
A group’s transform evaluated at one time, normalized.
EvaluatedVertex
A path vertex evaluated at one time, normalized.
IRect
A half-open rectangle of device pixels.
ItemPath
What item_paths reports of one item.
ScenePaint
The paint of a fill, with points normalized to the paint’s space and a transform from device pixels into that space.
SceneStop
One stop of a scene paint: its offset and straight, sRGB-encoded color.
StableHash
Two FNV-style lanes over the written bytes, matching the render graph’s keys.
StrokeStyle
A stroke’s style, in the pixels of the space it is drawn in.
VectorScene
Everything a content tree draws at one time and size.

Enums§

EvaluatedGeometry
A geometry item evaluated at one time.
EvaluatedItem
One content-tree item evaluated at one time.
PaintKind
What kind of paint covers a fill.
VectorOp
One drawing operation of a VectorScene.

Constants§

MAX_DEVICE
How far past the canvas, in device pixels, a path may reach before it is projected.

Functions§

build_scene
The scene items draw on a picture of size.
build_scene_in
The operations items draw in a space-sized box placed at origin on canvas, like an SVG viewBox. Positions and paints are normalized to space, and output is clipped to canvas. build_scene is the case space == canvas at the origin.
build_scene_with_items
The scene items draw, with each operation’s item name (empty for layer push and pop).
item_paths
Every item’s outline or painted area in document order, for queries.
project_far
path unchanged when it stays within MAX_DEVICE of a width by height canvas, otherwise projected onto the canvas plus a 64-pixel margin with every subpath closed. A non-finite coordinate yields an empty path.
scene_paint
paint as a scene paint, mapped by inverse from device pixels into a space-sized paint space.
stroke_outline
The outline style covers along path, transformed to device pixels by to_device.