summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/layer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-04 03:28:43 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-04 03:28:43 +0200
commit0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a (patch)
treec44e036220ea40734a00bb8e05e4afa6a9504bea /tiny_skia/src/layer.rs
parent87a613edd186461f1a8d224394043527a372571c (diff)
downloadiced-0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a.tar.gz
iced-0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a.tar.bz2
iced-0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a.zip
Implement image support for `canvas` widget
Diffstat (limited to 'tiny_skia/src/layer.rs')
-rw-r--r--tiny_skia/src/layer.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs
index 48fca1d8..9a169f46 100644
--- a/tiny_skia/src/layer.rs
+++ b/tiny_skia/src/layer.rs
@@ -117,6 +117,48 @@ 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,
+ );
+ }
+ Image::Vector {
+ handle,
+ color,
+ bounds,
+ rotation,
+ opacity,
+ } => {
+ self.draw_svg(
+ handle.clone(),
+ *color,
+ *bounds,
+ transformation,
+ *rotation,
+ *opacity,
+ );
+ }
+ }
+ }
+
+ pub fn draw_raster(
+ &mut self,
handle: image::Handle,
filter_method: image::FilterMethod,
bounds: Rectangle,
@@ -130,6 +172,7 @@ impl Layer {
bounds: bounds * transformation,
rotation,
opacity,
+ snap: false,
};
self.images.push(image);