bliss_paint/lib.rs
1//! Paint a [`bliss_dom::BaseDocument`] by pushing [`anyrender`] drawing commands into
2//! an impl [`anyrender::PaintScene`].
3
4mod color;
5mod debug_overlay;
6mod gradient;
7mod kurbo_css;
8mod layers;
9mod render;
10mod sizing;
11mod text;
12
13use anyrender::PaintScene;
14use bliss_dom::{BaseDocument, util::Color};
15use render::BlissDomPainter;
16
17/// Paint a [`bliss_dom::BaseDocument`] by pushing drawing commands into
18/// an impl [`anyrender::PaintScene`].
19///
20/// This function assumes that the styles and layout in the [`BaseDocument`] are already
21/// resolved. Please ensure that this is the case before trying to paint.
22///
23/// The implementation of [`PaintScene`] is responsible for handling the commands that are pushed into it.
24/// Generally this will involve executing them to draw a rasterized image/texture. But in some cases it may choose to
25/// transform them to a vector format (e.g. SVG/PDF) or serialize them in raw form for later use.
26pub fn paint_scene(
27 scene: &mut impl PaintScene,
28 dom: &BaseDocument,
29 scale: f64,
30 width: u32,
31 height: u32,
32 x_offset: u32,
33 y_offset: u32,
34) {
35 let generator =
36 BlissDomPainter::new(dom, scale, width, height, x_offset as f64, y_offset as f64);
37 generator.paint_scene(scene);
38
39 // println!(
40 // "Rendered using {} clips (depth: {}) (wanted: {})",
41 // CLIPS_USED.load(atomic::Ordering::SeqCst),
42 // CLIP_DEPTH_USED.load(atomic::Ordering::SeqCst),
43 // CLIPS_WANTED.load(atomic::Ordering::SeqCst)
44 // );
45}
46
47const SELECTION_COLOR: Color = Color::from_rgb8(180, 213, 255);