1use osmic_core::Color;
2
3#[derive(Debug, Clone)]
8pub struct SceneGraph {
9 pub background: Color,
10 pub layers: Vec<RenderLayer>,
11}
12
13impl SceneGraph {
14 pub fn new(background: Color) -> Self {
15 Self {
16 background,
17 layers: Vec::new(),
18 }
19 }
20
21 pub fn add_layer(&mut self, layer: RenderLayer) {
22 self.layers.push(layer);
23 }
24}
25
26#[derive(Debug, Clone)]
28pub struct RenderLayer {
29 pub z_order: i32,
30 pub features: Vec<RenderFeature>,
31}
32
33impl RenderLayer {
34 pub fn new(z_order: i32) -> Self {
35 Self {
36 z_order,
37 features: Vec::new(),
38 }
39 }
40
41 pub fn push(&mut self, feature: RenderFeature) {
42 self.features.push(feature);
43 }
44}
45
46#[derive(Debug, Clone)]
48pub enum RenderFeature {
49 Fill {
51 coords: Vec<Vec<[f32; 2]>>,
52 color: Color,
53 },
54 Stroke {
56 coords: Vec<[f32; 2]>,
57 color: Color,
58 width: f32,
59 cap: LineCap,
60 join: LineJoin,
61 },
62 Label {
64 position: [f32; 2],
65 text: String,
66 font_size: f32,
67 color: Color,
68 halo_color: Option<Color>,
69 halo_width: f32,
70 },
71}
72
73#[derive(Debug, Clone, Copy)]
74pub enum LineCap {
75 Butt,
76 Round,
77 Square,
78}
79
80#[derive(Debug, Clone, Copy)]
81pub enum LineJoin {
82 Miter,
83 Round,
84 Bevel,
85}