1#[derive(Clone, Debug)]
3pub enum Annotation {
4 Text {
6 label: String,
7 x: f64,
8 y: f64,
9 size: f64,
10 color: (u8, u8, u8),
11 },
12 Rect {
14 xmin: f64,
15 xmax: f64,
16 ymin: f64,
17 ymax: f64,
18 fill: (u8, u8, u8),
19 alpha: f64,
20 },
21 Segment {
23 x: f64,
24 y: f64,
25 xend: f64,
26 yend: f64,
27 color: (u8, u8, u8),
28 width: f64,
29 },
30}
31
32impl Annotation {
33 pub fn text(label: &str, x: f64, y: f64) -> Self {
35 Annotation::Text {
36 label: label.to_string(),
37 x,
38 y,
39 size: 12.0,
40 color: (50, 50, 50),
41 }
42 }
43
44 pub fn rect(xmin: f64, xmax: f64, ymin: f64, ymax: f64) -> Self {
46 Annotation::Rect {
47 xmin,
48 xmax,
49 ymin,
50 ymax,
51 fill: (200, 200, 200),
52 alpha: 0.3,
53 }
54 }
55
56 pub fn segment(x: f64, y: f64, xend: f64, yend: f64) -> Self {
58 Annotation::Segment {
59 x,
60 y,
61 xend,
62 yend,
63 color: (50, 50, 50),
64 width: 1.0,
65 }
66 }
67}