Implement image support for canvas widget

This commit is contained in:
Héctor Ramón Jiménez 2024-08-04 03:28:43 +02:00
parent 87a613edd1
commit 0ceee1cf3a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
16 changed files with 485 additions and 29 deletions

View file

@ -113,6 +113,49 @@ impl Layer {
}
pub fn draw_image(
&mut self,
image: &Image,
transformation: Transformation,
) {
match image {
Image::Raster {
handle,
filter_method,
bounds,
rotation,
opacity,
snap,
} => {
self.draw_raster(
handle.clone(),
*filter_method,
*bounds,
transformation,
*rotation,
*opacity,
*snap,
);
}
Image::Vector {
handle,
color,
bounds,
rotation,
opacity,
} => {
self.draw_svg(
handle.clone(),
*color,
*bounds,
transformation,
*rotation,
*opacity,
);
}
}
}
pub fn draw_raster(
&mut self,
handle: crate::core::image::Handle,
filter_method: crate::core::image::FilterMethod,
@ -120,6 +163,7 @@ impl Layer {
transformation: Transformation,
rotation: Radians,
opacity: f32,
snap: bool,
) {
let image = Image::Raster {
handle,
@ -127,6 +171,7 @@ impl Layer {
bounds: bounds * transformation,
rotation,
opacity,
snap,
};
self.images.push(image);