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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::color::Color;
use crate::drawing::Renderable;
use crate::Graphics;
use graphics_shapes::coord::Coord;
use ici_files::animated::AnimatedIndexedImage;
use ici_files::prelude::IndexedImage;
use ici_files::IciColor;
impl From<IciColor> for Color {
fn from(value: IciColor) -> Self {
Color::rgba(value.r, value.g, value.b, value.a)
}
}
pub struct RenderableIndexedImage {
pub xy: Coord,
pub image: IndexedImage,
}
impl RenderableIndexedImage {
pub fn new(xy: Coord, image: IndexedImage) -> Self {
Self { xy, image }
}
}
impl Renderable<RenderableIndexedImage> for RenderableIndexedImage {
fn render(&self, graphics: &mut Graphics) {
graphics.draw_indexed_image(self.xy, &self.image);
}
}
pub struct RenderableAnimatedImage {
pub xy: Coord,
pub image: AnimatedIndexedImage,
}
impl RenderableAnimatedImage {
pub fn new(xy: Coord, image: AnimatedIndexedImage) -> Self {
Self { xy, image }
}
}
impl Renderable<RenderableAnimatedImage> for RenderableAnimatedImage {
fn render(&self, graphics: &mut Graphics) {
graphics.draw_animated_image(self.xy, &self.image);
}
}
impl RenderableAnimatedImage {
pub fn update(&mut self, delta: f64) {
self.image.update(delta);
}
}