Skip to main content

Crate rusty_mermaid_core

Crate rusty_mermaid_core 

Source
Expand description

Foundation crate for rusty-mermaid: primitives, Scene, Theme, geometry, and text measurement.

This crate defines the universal intermediate representation that all diagram types produce and all rendering backends consume. The central type is Scene, a collection of Primitive drawing elements (rects, circles, paths, text, etc.) that is completely backend-agnostic.

§Key types

§Key traits

§Examples

use rusty_mermaid_core::{
    Scene, Primitive, Style, Color, Point, BBox, TextStyle, TextAnchor,
};

let mut scene = Scene::new(200.0, 100.0);

// Add a filled rectangle
scene.push(Primitive::Rect {
    bbox: BBox::new(100.0, 50.0, 120.0, 40.0),
    rx: 4.0,
    ry: 4.0,
    style: Style {
        fill: Some(Color::rgb(236, 236, 255)),
        stroke: Some(Color::rgb(147, 112, 219)),
        stroke_width: Some(2.0),
        ..Style::default()
    },
});

// Add a text label
scene.push(Primitive::Text {
    position: Point::new(100.0, 50.0),
    content: "Hello".into(),
    anchor: TextAnchor::Middle,
    style: TextStyle::default(),
});

assert_eq!(scene.len(), 2);

Re-exports§

pub use curve::CurveType;
pub use curve::interpolate;
pub use geometry::arc_sector_segments;
pub use geometry::intersect_circle;
pub use geometry::intersect_ellipse;
pub use geometry::intersect_line_circle;
pub use geometry::intersect_line_ellipse;
pub use geometry::intersect_polygon;
pub use geometry::intersect_rect;
pub use marker_shapes::MarkerGeometry;
pub use marker_shapes::MarkerPath;
pub use marker_shapes::MarkerShape;
pub use marker_shapes::marker_geometry;
pub use marker_shapes::marker_path;
pub use marker_shapes::transform_marker_circle;
pub use marker_shapes::transform_marker_curves;
pub use marker_shapes::transform_marker_points;
pub use renderer::Renderer;
pub use scene::Element;
pub use scene::ElementId;
pub use scene::ElementKind;
pub use scene::MarkerType;
pub use scene::PathSegment;
pub use scene::Primitive;
pub use scene::Scene;
pub use scene::TextAnchor;
pub use scene::Transform;
pub use scene::path_end_tangent;
pub use scene::path_start_tangent;
pub use shape::Shape;
pub use style::FontWeight;
pub use style::Style;
pub use style::TextStyle;
pub use style::Theme;
pub use text::MdSpan;
pub use text::SimpleTextMeasure;
pub use text::TextMeasure;
pub use text::TextSize;
pub use text::parse_inline_markdown;
pub use text::text_baseline_y_offset;
pub use types::BBox;
pub use types::Color;
pub use types::Direction;
pub use types::Point;

Modules§

constants
curve
font_fallback
force_layout
CoSE (Compound Spring Embedder) force-directed layout.
geometry
marker_shapes
renderer
scene
shape
style
text
types