Skip to main content

Crate zenith_scene

Crate zenith_scene 

Source
Expand description

Backend-neutral scene IR and scene compilation for Zenith.

Owns the display-list primitives (FillRect, DrawGlyphRun, PushClip, etc.), scene compilation from a validated AST into a z-ordered display list, opacity/visibility/clip resolution, and exclusion of non-printing nodes.

This crate is the stable contract boundary that every future backend — GPU, PDF, SVG export — will consume.

§Module layout

  • ir — scene IR types (Scene, SceneCommand, Color, SceneGlyph).
  • color — sRGB hex parsing → Color.
  • compilecompile(&Document, &dyn FontProvider) -> CompileResult.

§Quick start

use zenith_scene::{Scene, SceneCommand, Color, Paint};

let mut scene = Scene::new(640.0, 360.0);
scene.commands.push(SceneCommand::FillRect {
    x: 0.0, y: 0.0, w: 640.0, h: 360.0,
    paint: Paint::solid(Color::srgb(248, 250, 252, 255)),
});
let json = scene.to_json().expect("serializes");
assert!(json.contains("zenith-scene-v1"));

Compile a parsed document into a scene with compile.

Re-exports§

pub use compile::CompileResult;
pub use compile::compile;
pub use compile::compile_page;
pub use ir::BlendMode;
pub use ir::Color;
pub use ir::FilterSpec;
pub use ir::FitMode;
pub use ir::GradientPaint;
pub use ir::GradientStop;
pub use ir::ImageClip;
pub use ir::LineCap;
pub use ir::MaskShape;
pub use ir::MaskSpec;
pub use ir::Paint;
pub use ir::Rect;
pub use ir::Scene;
pub use ir::SceneCommand;
pub use ir::SceneGlyph;
pub use ir::ShadowSpec;
pub use ir::SrcRect;
pub use ir::StrokeAlign;

Modules§

color
sRGB hex color parsing.
compile
Scene compilation: DocumentCompileResult.
ir
Scene IR — the backend-neutral display-list primitives.