Expand description
§lievisual
Declarative visual scene (IR) + pluggable rendering backends.
§Design overview
- IR / backend separation:
scenedescribes what to draw (primitives + layeredz_index+ transforms + node attributes), whilerender::Rendererdescribes how. Adding a backend (SVG / vello_cpu / GPU) requires no changes to the IR. - Unified layering and transforms:
z_index/Transformare promoted to fields ofscene::SceneNode; node-levelopacity/name/visible/clipalso belong to the node (recursively applied to a Group subtree), so new primitive variants need no field churn. - Layers:
scene::Scenemay carry an ordered set ofscene::Layer(bottom to top) that controlsvisible/opacity/transform/namefor the whole layer; nodes inside are then stably sorted byz_index.nodesis kept as the default (bottom-most) layer. - Rich primitives:
scene::Elementprovides rectangles, circles, ellipses, rounded rectangles, lines, polylines, polygons, arcs, sectors, paths, gradient paths, text, and groups — covering common chart / flowchart / Markdown needs. - Varied fills: solid color, linear gradient, radial gradient (
scene::Fill); strokes support line caps / joins, dashes (dash_array/dash_offset), andmiter_limit. - Path operations (
path): boolean combinations (union/intersect/difference/xor), stroke-to-path (outline), arc-length measurement (path_length/point_at_length/trim) and offset / inset — all build-time ongeometry::BezPath, so results render identically on every backend. Boolean ops flatten curves (viai_overlay), so their output is polygonal. - Hand-drawn style (opt-in):
sketchis a post-pass that turns selected elements into rough, pen-drawn outlines plusscene::Fill::Sketchfills. It never runs on its own: callsketch::roughen_scene(or the selectivesketch::roughen_scene_if) to enable it, and pick which element kinds participate withsketch::SketchOptions::kinds. - Text (rich-text core):
scene::Element::Textis built around styled spans (text::RichSpan); typesetting / measurement go through the&[RichSpan]entry points (text::measure_text/text::layout_text); it can carry a pre-laid-outtext::TextLayout. Raster backends draw glyphs precisely via layout, while the SVG backend falls back to<text>.
§Backend support (all rendering backends enabled by default, no feature gate)
render::SvgRenderer: emits a vector SVG string, with scene metadata (title/description/scale).render::VelloPixmapRenderer: vello_cpu rasterization → PNG bytes.
§Geometry and coordinates
Geometric base types (Point / Rect / BezPath / Affine, etc.) are re-exported
directly from kurbo (see geometry), giving zero-cost interoperability with the internal
geometry types of vello / parley; Color / Transform are defined by lievisual itself.
Re-exports§
pub use fit::FitOptions;pub use fit::fit_scene;pub use fit::scene_bounds;pub use geometry::Color;pub use geometry::PointExt;pub use geometry::Transform;pub use path::BoolOp;pub use path::DEFAULT_TOLERANCE;pub use path::PathOps;pub use path::PathSample;pub use pixmap::Pixmap;pub use scene::BlendMode;pub use scene::Clip;pub use scene::ColorMatrix;pub use scene::CornerRadii;pub use scene::Element;pub use scene::Fill;pub use scene::FillStrokeStyle;pub use scene::Filter;pub use scene::GradientSpread;pub use scene::GradientStop;pub use scene::ImageFill;pub use scene::ImageQuality;pub use scene::Layer;pub use scene::LineCap;pub use scene::LineJoin;pub use scene::LinearGradient;pub use scene::Mask;pub use scene::NodeKind;pub use scene::ObjectFit;pub use scene::RadialGradient;pub use scene::Scene;pub use scene::SceneImage;pub use scene::SceneNode;pub use scene::SketchFill;pub use scene::SketchFillStyle;pub use scene::Stroke;pub use scene::SweepGradient;pub use sketch::SketchKind;pub use sketch::SketchKinds;pub use sketch::SketchOptions;pub use sketch::roughen_element;pub use sketch::roughen_scene;pub use sketch::roughen_scene_fit;pub use sketch::roughen_scene_fit_if;pub use sketch::roughen_scene_if;pub use text::FontSource;pub use text::FontStyle;pub use text::FontWeight;pub use text::FontWidth;pub use text::Glyph;pub use text::LineMetrics;pub use text::RichSpan;pub use text::TextAlign;pub use text::TextBaseline;pub use text::TextDecoration;pub use text::TextLayout;pub use text::TextLine;pub use text::TextMeasure;pub use text::TextMetrics;pub use text::TextRun;pub use text::TextStyle;pub use text::compute_text_offset;pub use text::layout_metrics;pub use text::layout_text;pub use text::measure_text;pub use text::parse_generic_family;pub use text::register_font;pub use text::register_font_generic;pub use parley;pub use kurbo;
Modules§
- builder
- Canvas-style convenience construction layer (builder / sugar): an immutable superset of the Web Canvas 2D drawing vocabulary.
- fit
- Content-bounds computation and “fit the canvas to the content” helpers.
- geometry
- Geometric and color base types.
- path
- Path operations: boolean combinations, stroke-to-path, arc-length measurement and offset / inset.
- pixmap
- Self-contained RGBA8 bitmap (pixmap).
- render
- Rendering backend trait and default traversal logic.
- scene
- Declarative scene-graph IR.
- sketch
- Hand-drawn (“sketch”) rendering — an opt-in post-pass over a [
Scene]. - text
- Text layout support (modeled after the Web Canvas text API).
Structs§
- Affine
- A 2D affine transform.
- Arc
- A single elliptical arc segment.
- BezPath
- A Bézier path.
- Circle
- A circle.
- Circle
Segment - A segment of a circle.
- Cubic
Bez - A single cubic Bézier segment.
- Cubic
BezIter - An iterator for cubic beziers.
- Diagonal2
- A diagonal matrix, suitable for representing anisotropic scaling.
- Ellipse
- An ellipse.
- Insets
- Insets from the edges of a rectangle.
- Line
- A single line.
- Line
Intersection - An intersection of a
Lineand aPathSeg. - MinDistance
- The minimum distance between two Bézier curves.
- Moments
- A collect of moment integrals for a path, used for computing shape properties like area, centroid, and inertia.
- Path
SegIter - An iterator for path segments.
- Point
- A 2D point.
- QuadBez
- A single quadratic Bézier segment.
- Quad
BezIter - An iterator for quadratic beziers.
- Quad
Spline - A quadratic Bézier spline in B-spline format.
- Rect
- A rectangle.
- Rounded
Rect - A rectangle with rounded corners.
- Rounded
Rect Radii - Radii for each corner of a rounded rectangle.
- Segments
- An iterator that transforms path elements to path segments.
- Size
- A 2D size.
- Translate
Scale - A transformation consisting of a uniform scaling followed by a translation.
- Triangle
- Triangle
- Vec2
- A 2D vector.
Enums§
- Axis
- An axis in the plane.
- Cusp
Type - Classification result for cusp detection.
- PathEl
- The element of a Bézier path.
- PathSeg
- A segment of a Bézier path.
Traits§
- Shape
- A generic trait for open and closed shapes.