Skip to main content

Module vector

Module vector 

Source
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§

CompileCache
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.
SurfaceTriangle
A nondegenerate tree-space triangle in a filled geometric union.
VectorGroup
A shared coordinate/isolation group, including source provenance.
VectorImage
A bitmap leaf; its surrounding group supplies any affine placement.
VectorLeaf
A leaf occurrence with complete world coordinates and inherited metadata.
VectorMask
A shared coordinate/isolation group, including source provenance.
VectorPath
A painted path in its containing group’s local coordinates.
VectorSelection
Authored modifier applied to the original vector groups at known addresses.
VectorSurface
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.
VectorTree
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).
WriteOptions
Shared cumulative-length handwriting and fill handoff settings.

Enums§

VectorItem
A semantic leaf or group, retained in paint order.