rustmotion_core/traits/
painter.rs1use skia_safe::Canvas;
2
3use crate::engine::animator::AnimatedProperties;
4use crate::engine::box_tree::AvailableSpace;
5use crate::engine::layout_pass::BoxLayout;
6
7#[derive(Debug, Clone, Copy)]
8pub struct PaintCtx {
9 pub time: f64,
10 pub scenario_time: f64,
11 pub scene_duration: f64,
12 pub frame_index: u32,
13 pub fps: u32,
14 pub video_width: u32,
15 pub video_height: u32,
16 pub stagger_offset: f64,
17}
18
19#[derive(Debug, Clone, Copy)]
20pub struct AvailableSize {
21 pub width: AvailableSpace,
22 pub height: AvailableSpace,
23}
24
25#[derive(Debug, Clone, Copy)]
26pub struct MeasureCtx {
27 pub video_width: u32,
28 pub video_height: u32,
29}
30
31pub trait Painter {
32 fn paint_content(
33 &self,
34 canvas: &Canvas,
35 layout: &BoxLayout,
36 props: &AnimatedProperties,
37 ctx: &PaintCtx,
38 );
39
40 fn intrinsic_size(&self, _available: AvailableSize, _ctx: &MeasureCtx) -> Option<(f32, f32)> {
41 None
42 }
43}