pub struct Scene {
pub schema: &'static str,
pub width: f64,
pub height: f64,
pub commands: Vec<SceneCommand>,
pub trim: Option<Rect>,
}Expand description
A fully resolved, backend-neutral display list.
The schema field is always "zenith-scene-v1" and is declared first so
that it serializes as the first key in the JSON output, satisfying the
normative requirement from the format spec.
Fields§
§schema: &'static strAlways "zenith-scene-v1". Declared first so it appears first in JSON.
width: f64Page / canvas width in pixels.
height: f64Page / canvas height in pixels.
commands: Vec<SceneCommand>Ordered display list. Paint order: index 0 is painted first (bottom).
trim: Option<Rect>Print trim box in scene (top-left origin, y-down) pixel coordinates.
Some only when the page declared a positive bleed margin: then
width/height are the full media box (including bleed) and trim is
the inner page rectangle [b, b, page_w, page_h]. None when there is
no bleed (trim == media box). Skipped in JSON when absent so existing
non-bleed scenes serialize byte-identically.
Implementations§
Source§impl Scene
impl Scene
Sourcepub fn new(width: f64, height: f64) -> Self
pub fn new(width: f64, height: f64) -> Self
Construct an empty scene for the given page dimensions.
schema is always set to "zenith-scene-v1".
Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Serialize this scene to a pretty-printed JSON string.
Uses serde_json::to_string_pretty which produces deterministic output
because Scene and its fields use only Vec (ordered) and struct
(stable field order in Rust + serde), never HashMap.
§Errors
Returns an error only if serialization fails, which cannot happen for
the types used in Scene (all fields are plain numerics, strings, and
u8s). The Result is kept for API robustness.