Skip to main content

Crate lievisual

Crate lievisual 

Source
Expand description

§lievisual

Declarative visual scene (IR) + pluggable rendering backends.

§Design overview

  • IR / backend separation: scene describes what to draw (primitives + layered z_index + transforms + node attributes), while render::Renderer describes how. Adding a backend (SVG / vello_cpu / GPU) requires no changes to the IR.
  • Unified layering and transforms: z_index / Transform are promoted to fields of scene::SceneNode; node-level opacity / name / visible / clip also belong to the node (recursively applied to a Group subtree), so new primitive variants need no field churn.
  • Layers: scene::Scene may carry an ordered set of scene::Layer (bottom to top) that controls visible / opacity / transform / name for the whole layer; nodes inside are then stably sorted by z_index. nodes is kept as the default (bottom-most) layer.
  • Rich primitives: scene::Element provides 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), and miter_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 on geometry::BezPath, so results render identically on every backend. Boolean ops flatten curves (via i_overlay), so their output is polygonal.
  • Hand-drawn style (opt-in): sketch is a post-pass that turns selected elements into rough, pen-drawn outlines plus scene::Fill::Sketch fills. It never runs on its own: call sketch::roughen_scene (or the selective sketch::roughen_scene_if) to enable it, and pick which element kinds participate with sketch::SketchOptions::kinds.
  • Text (rich-text core): scene::Element::Text is 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-out text::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)

§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.
CircleSegment
A segment of a circle.
CubicBez
A single cubic Bézier segment.
CubicBezIter
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.
LineIntersection
An intersection of a Line and a PathSeg.
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.
PathSegIter
An iterator for path segments.
Point
A 2D point.
QuadBez
A single quadratic Bézier segment.
QuadBezIter
An iterator for quadratic beziers.
QuadSpline
A quadratic Bézier spline in B-spline format.
Rect
A rectangle.
RoundedRect
A rectangle with rounded corners.
RoundedRectRadii
Radii for each corner of a rounded rectangle.
Segments
An iterator that transforms path elements to path segments.
Size
A 2D size.
TranslateScale
A transformation consisting of a uniform scaling followed by a translation.
Triangle
Triangle
Vec2
A 2D vector.

Enums§

Axis
An axis in the plane.
CuspType
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.