rusty_mermaid_core/lib.rs
1//! Foundation crate for rusty-mermaid: primitives, Scene, Theme, geometry, and text measurement.
2//!
3//! This crate defines the universal intermediate representation that all diagram
4//! types produce and all rendering backends consume. The central type is [`Scene`],
5//! a collection of [`Primitive`] drawing elements (rects, circles, paths, text, etc.)
6//! that is completely backend-agnostic.
7//!
8//! # Key types
9//!
10//! - [`Scene`] / [`Primitive`] -- the contract between layout and rendering
11//! - [`Theme`] / [`Style`] / [`TextStyle`] -- visual configuration
12//! - [`Color`] / [`Point`] / [`BBox`] -- geometric primitives
13//! - [`Shape`] -- node shape catalog (rect, diamond, circle, etc.)
14//! - [`Direction`] -- layout flow direction (TB, BT, LR, RL)
15//!
16//! # Key traits
17//!
18//! - [`Renderer`] -- backends implement this to consume a [`Scene`]
19//! - [`TextMeasure`] -- text dimension measurement for layout
20//!
21//! # Examples
22//!
23//! ```
24//! use rusty_mermaid_core::{
25//! Scene, Primitive, Style, Color, Point, BBox, TextStyle, TextAnchor,
26//! };
27//!
28//! let mut scene = Scene::new(200.0, 100.0);
29//!
30//! // Add a filled rectangle
31//! scene.push(Primitive::Rect {
32//! bbox: BBox::new(100.0, 50.0, 120.0, 40.0),
33//! rx: 4.0,
34//! ry: 4.0,
35//! style: Style {
36//! fill: Some(Color::rgb(236, 236, 255)),
37//! stroke: Some(Color::rgb(147, 112, 219)),
38//! stroke_width: Some(2.0),
39//! ..Style::default()
40//! },
41//! });
42//!
43//! // Add a text label
44//! scene.push(Primitive::Text {
45//! position: Point::new(100.0, 50.0),
46//! content: "Hello".into(),
47//! anchor: TextAnchor::Middle,
48//! style: TextStyle::default(),
49//! });
50//!
51//! assert_eq!(scene.len(), 2);
52//! ```
53
54pub mod constants;
55pub mod curve;
56pub mod font_fallback;
57pub mod force_layout;
58pub mod geometry;
59pub mod marker_shapes;
60pub mod renderer;
61pub mod scene;
62pub mod shape;
63pub mod style;
64pub mod text;
65pub mod types;
66
67pub use curve::{CurveType, interpolate};
68pub use geometry::{
69 arc_sector_segments, intersect_circle, intersect_ellipse, intersect_line_circle,
70 intersect_line_ellipse, intersect_polygon, intersect_rect,
71};
72pub use marker_shapes::{
73 MarkerGeometry, MarkerPath, MarkerShape, marker_geometry, marker_path, transform_marker_circle,
74 transform_marker_curves, transform_marker_points,
75};
76pub use renderer::Renderer;
77pub use scene::{
78 Element, ElementId, ElementKind, MarkerType, PathSegment, Primitive, Scene, TextAnchor,
79 Transform, path_end_tangent, path_start_tangent,
80};
81pub use shape::Shape;
82pub use style::{FontWeight, Style, TextStyle, Theme};
83pub use text::{
84 MdSpan, SimpleTextMeasure, TextMeasure, TextSize, parse_inline_markdown, text_baseline_y_offset,
85};
86pub use types::{BBox, Color, Direction, Point};