Skip to main content

euv_chart/backend/canvas2d/
struct.rs

1use super::*;
2
3/// The Canvas2D rendering backend.
4///
5/// This is the universal fallback: it works in every browser, including
6/// ones with neither WebGPU nor WebGL2. It replays the display list as
7/// immediate-mode canvas calls, which is slower than the GPU backends but
8/// produces exactly the same picture.
9#[derive(Clone, Data, Debug)]
10pub struct Canvas2dChartBackend {
11    /// The canvas the chart draws into.
12    #[get(pub(crate))]
13    #[get_mut(pub(crate))]
14    #[set(pub(crate))]
15    pub(crate) canvas: HtmlCanvasElement,
16    /// The 2D rendering context.
17    #[get(pub(crate))]
18    #[get_mut(pub(crate))]
19    #[set(pub(crate))]
20    pub(crate) context: CanvasRenderingContext2d,
21    /// The device pixel ratio the context is currently scaled by.
22    #[get(pub(crate), type(copy))]
23    #[get_mut(pub(crate))]
24    #[set(pub(crate))]
25    pub(crate) dpr: f64,
26    /// The logical width of the canvas, in CSS pixels.
27    #[get(pub(crate), type(copy))]
28    #[get_mut(pub(crate))]
29    #[set(pub(crate))]
30    pub(crate) width: f64,
31    /// The logical height of the canvas, in CSS pixels.
32    #[get(pub(crate), type(copy))]
33    #[get_mut(pub(crate))]
34    #[set(pub(crate))]
35    pub(crate) height: f64,
36}