1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! # `canvist_paint`
//!
//! Rendering for canvist's canvas. The scene walker turns one page of a
//! scene into [`Painter`] calls, culled to the viewport with level of
//! detail, and every backend implements [`Painter`]:
//!
//! - [`VelloPainter`] (feature `gpu`): vello on wgpu, for WebGPU in browsers
//! and Metal, Vulkan, and DX12 natively;
//! - [`CpuPainter`] (feature `cpu`): `vello_cpu`, for PNG export, server
//! thumbnails, and the browser fallback where WebGPU is missing;
//! - [`SvgPainter`]: SVG documents, with text kept as text;
//! - [`Recorder`]: the calls themselves, for tests.
//!
//! Text frames draw their `canvist_layout` display list. The GPU and CPU
//! backends shape runs with `parley` and the bundled font the canvas
//! measures with, so glyphs land where layout put them.
//!
//! # Example
//!
//! ```
//! use std::sync::Arc;
//!
//! use canvist_canvas::Canvas;
//! use canvist_canvas::Shapes;
//! use canvist_canvas::TextLayouts;
//! use canvist_layout::FixedMeasurer;
//! use canvist_layout::Theme;
//! use canvist_paint::Assets;
//! use canvist_paint::Sources;
//! use canvist_paint::SvgPainter;
//! use canvist_paint::View;
//! use canvist_scene::Props;
//! use canvist_scene::Scene;
//! use kurbo::Size;
//! use kurbo::Vec2;
//!
//! let mut builder = Canvas::builder();
//! builder.add(Shapes);
//! let mut scene = Scene::new(builder.schema()?, 1)?;
//! let page = scene.pages()[0];
//! let mut transaction = scene.transaction();
//! transaction.insert(page, None, "ellipse", Props {
//! size: Vec2::new(80.0, 40.0),
//! fills: Arc::new([canvist_scene::Paint::solid(canvist_scene::Color::rgb(59, 44, 245))]),
//! ..Props::default()
//! })?;
//! let _ = transaction.commit();
//! let canvas = builder.build(scene, TextLayouts::new(Arc::new(Theme::starter_kit()), FixedMeasurer::new()))?;
//! let state = canvas.state();
//! let assets = Assets::new();
//! let sources = Sources { scene: state.scene(), index: state.index(), texts: state.texts(), assets: &assets };
//! let view = View { camera: *state.camera(), viewport: Size::new(200.0, 100.0), quality: Default::default() };
//!
//! let mut svg = SvgPainter::new(view.viewport);
//! canvist_paint::paint_page(&mut svg, &sources, page, &view);
//! assert!(svg.finish().contains("fill=\"#3b2cf5ff\""));
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use Assets;
pub use ChromeStyle;
pub use paint_overlay;
pub use CpuError;
pub use CpuPainter;
pub use DisplayStyle;
pub use GREEK_PIXELS;
pub use paint_display_list;
pub use VelloPainter;
pub use BoxShadow;
pub use Draw;
pub use Image;
pub use Layer;
pub use Painter;
pub use Text;
pub use peniko;
pub use PaintOp;
pub use Recorder;
pub use SvgPainter;
pub use BUNDLED_FONT;
pub use Glyph;
pub use ShapedRun;
pub use Shaper;
pub use Transformed;
pub use vello;
pub use LOD_PIXELS;
pub use MIN_PIXELS;
pub use Quality;
pub use Sources;
pub use View;
pub use paint_nodes;
pub use paint_page;
/// The fill rule a shape's outline uses.
pub