Skip to main content

zenith_scene/
lib.rs

1//! Backend-neutral scene IR and scene compilation for Zenith.
2//!
3//! Owns the display-list primitives (`FillRect`, `DrawGlyphRun`, `PushClip`,
4//! etc.), scene compilation from a validated AST into a z-ordered display list,
5//! opacity/visibility/clip resolution, and exclusion of non-printing nodes.
6//!
7//! This crate is the stable contract boundary that every future backend —
8//! GPU, PDF, SVG export — will consume.
9//!
10//! # Module layout
11//!
12//! - `ir`      — scene IR types (`Scene`, `SceneCommand`, `Color`, `SceneGlyph`).
13//! - `color`   — sRGB hex parsing → `Color`.
14//! - `compile` — `compile(&Document, &dyn FontProvider) -> CompileResult`.
15//!
16//! # Quick start
17//!
18//! ```rust
19//! use zenith_scene::{Scene, SceneCommand, Color, Paint};
20//!
21//! let mut scene = Scene::new(640.0, 360.0);
22//! scene.commands.push(SceneCommand::FillRect {
23//!     x: 0.0, y: 0.0, w: 640.0, h: 360.0,
24//!     paint: Paint::solid(Color::srgb(248, 250, 252, 255)),
25//! });
26//! let json = scene.to_json().expect("serializes");
27//! assert!(json.contains("zenith-scene-v1"));
28//! ```
29//!
30//! Compile a parsed document into a scene with
31//! [`compile`](crate::compile::compile).
32
33pub mod color;
34pub mod compile;
35pub mod ir;
36
37// Curated flat re-exports.
38pub use compile::{CompileResult, compile, compile_page};
39pub use ir::{
40    BlendMode, Color, FilterSpec, FitMode, GradientPaint, GradientStop, ImageClip, LineCap,
41    MaskShape, MaskSpec, Paint, Rect, Scene, SceneCommand, SceneGlyph, ShadowSpec, SrcRect,
42    StrokeAlign,
43};