Expand description
Shared immutable semantic vectors for text, SVG, formulas and vector effects.
use motion_content::prelude::*;
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourceStore, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
use motion_render::{Composition, RenderPrepare, RenderOptions, BackendKind, render_still};
let tree = VectorTree::new(
Rect::new(0.0, 0.0, 16.0, 16.0),
VectorGroup {
children: vec![VectorItem::Path(VectorPath::filled(
Path2D::from_rect(Rect::new(2.0, 2.0, 14.0, 14.0))?,
Color::WHITE,
))],
..VectorGroup::default()
},
)?;
assert_eq!(tree.surface()?.area(), 144.0);
assert_eq!(tree.sample_points(32, 42)?, tree.sample_points(32, 42)?);
let ink = tree.write(0.5, WriteOptions::default())?;
let morph = Morph::new(&tree, &tree)?;
let frame = morph
.sample(0.5)?
.compile(
Size::new(16.0, 16.0),
PixelSize::new(16, 16),
ValidationLimits::default(),
)?
.prepare(ValidationLimits::default(), RasterLimits::default())?
.render_linear(RasterLimits::default())?;
assert_eq!(frame.linear_pixel(8, 8), Some([1.0; 4]));Modules§
- ink
- Deterministic ink materials and pressure-sensitive drawing.
Structs§
- Compile
Cache - A compile cache created from one immutable key.
- Morph
- Prepared, replayable semantic tree morph. Leaf IDs take priority, followed by position and signed-curve-area magnitude. Unmatched parts grow/shrink at their own center. Fill/stroke/image geometry shares MorphPath’s original curves. Spatial paints and differing clipping/isolation crossfade the two retained hierarchies; solid colors interpolate in Oklab on the morphed geometry.
- Surface
Triangle - A nondegenerate tree-space triangle in a filled geometric union.
- Vector
Group - A shared coordinate/isolation group, including source provenance.
- Vector
Image - A bitmap leaf; its surrounding group supplies any affine placement.
- Vector
Leaf - A leaf occurrence with complete world coordinates and inherited metadata.
- Vector
Mask - A shared coordinate/isolation group, including source provenance.
- Vector
Path - A painted path in its containing group’s local coordinates.
- Vector
Selection - Authored modifier applied to the original vector groups at known addresses.
- Vector
Surface - Immutable prepared fill silhouette for deterministic area-uniform sampling. Images/strokes are not filled path regions. Paint alpha is not a density; zero-opacity groups are omitted, clips/holes and overlapping fills are honored.
- Vector
Tree - Immutable, cheaply cloned group/path/image tree with unique ID lookup. Construction validates every branch, including invisible ones, under bounded depth (48), items (8192), IDs (1024 bytes each) and aggregate verbs (262144).
- Write
Options - Shared cumulative-length handwriting and fill handoff settings.
Enums§
- Vector
Item - A semantic leaf or group, retained in paint order.