1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::{position::Rect, style::Style, Shape, ShapeType};
#[derive(Debug, Clone)]
pub enum ImageFormat {
PNG(Vec<u8>),
JPEG(Vec<u8>),
}
#[derive(Debug, Clone)]
pub struct Image {
pub(crate) pos: Rect,
pub(crate) style: Option<Style>,
pub(crate) data: ImageFormat,
}
crate::impl_pos!(Image);
crate::impl_style!(Image);
impl Image {
pub fn new(data: ImageFormat) -> Image {
Image {
pos: Rect::new(),
style: None,
data,
}
}
}
impl Into<Shape> for Image {
fn into(self) -> Shape {
Shape {
pos: self.pos,
style: self.style,
shape_type: ShapeType::Image { data: self.data },
}
}
}