Skip to main content

Crate alpha2_geometry

Crate alpha2_geometry 

Source
Expand description

Deterministic vector geometry for alpha2 shapes.

A shapes generator’s content tree, evaluated at one time (EvaluatedItem), becomes a VectorScene: fills and stroke outlines in device pixels, in drawing order, with the group layers that fade them. raster::rasterize turns one of its paths into tile coverage. Queries the editor needs (bounds, hit tests, lengths, trims) use the same code.

Every result is the same bits on every target. Geometry is f64, trigonometry is libm’s, arc lengths and flattening use only + - * / and sqrt, and coverage is accumulated in scalar f32 in a fixed order. Stroke expansion is kurbo’s, and its transcendental calls are libm’s too, unless another crate in the build turns on kurbo’s std: then outlines and scene keys can differ in the last bits, and the shared hash goldens compare coverage only.

Re-exports§

pub use kurbo;

Modules§

affine
Affine transforms built from libm, and lengths from sqrt alone, so they are the same bits on every target.
arclen
Arc lengths of path segments, from + - * / and sqrt alone.
query
What an editor asks of shapes: where items are, which one is under a point, how long a path is, and paths cut, resampled, or converted. Each answer comes from the code the renderer draws with.
raster
Coverage of a path: per pixel, the average winding number over the pixel’s area, mapped by the fill rule, in 16 by 16 pixel tiles.
shapes
Parametric shapes as Bezier paths in pixel space, with the start points and directions After Effects and Lottie give them, so a trim cuts them where it cuts there.
spatial
Motion along spatial curves: a position keyframed with tangents travels along the cubic Bezier between its keyframes at the speed its timing curve sets, along the curve’s length.
trim
Trim paths: keeping a span of geometry’s length.

Structs§

CanvasSize
The size, in device pixels, of the picture a content tree is drawn on: normalized (1, 1) is (width, height), and 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, as the generator pass reads a paint: points in the normalized coordinates of the paint’s space, and the transform from device pixels into that space’s pixels.
SceneStop
One stop of a scene paint: its offset and straight, sRGB-encoded color.
StableHash
Two FNV-style lanes over the bytes written, as the render graph keys its results.
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 and still be rasterized as it is.

Functions§

build_scene
The scene items draw on a picture of size.
build_scene_in
The operations items draw on a picture of space whose top-left corner lies at origin on a canvas of canvas, as an SVG viewBox places its picture: positions are normalized to space, lengths are fractions of its shorter side, and paints are in it. What they cover is clipped to canvas. build_scene is the case space == canvas at the origin.
build_scene_with_items
The scene items draw, with the item each of its operations was drawn for (empty for a layer’s push and pop).
item_paths
Every item’s outline or painted area, in document order, for the editor’s queries.
project_far
path as it fills a width by height canvas: itself when it stays within MAX_DEVICE of the canvas, or projected onto the canvas and a 64-pixel margin around it. Every subpath of the projection is closed, as filling closes it. A non-finite coordinate leaves nothing.
scene_paint
paint as the scene paints it, through inverse from device pixels into a paint space of space pixels.
stroke_outline
The outline style covers along path, both in the space to_device takes to device pixels, there. The pen is round in path’s space, so a non-uniform transform makes it an ellipse, as After Effects draws it. Empty for a width of zero or less.