open_sesame/render/
context.rs1use crate::config::Config;
4use tiny_skia::Pixmap;
5
6pub struct RenderContext<'a> {
8 pub pixmap: &'a mut Pixmap,
10 pub scale: f32,
12 pub config: &'a Config,
14}
15
16impl<'a> RenderContext<'a> {
17 pub fn new(pixmap: &'a mut Pixmap, scale: f32, config: &'a Config) -> Self {
19 Self {
20 pixmap,
21 scale,
22 config,
23 }
24 }
25
26 pub fn width(&self) -> u32 {
28 self.pixmap.width()
29 }
30
31 pub fn height(&self) -> u32 {
33 self.pixmap.height()
34 }
35
36 pub fn scaled(&self, value: f32) -> f32 {
38 value * self.scale
39 }
40}