diff options
author | 2024-08-04 03:28:43 +0200 | |
---|---|---|
committer | 2024-08-04 03:28:43 +0200 | |
commit | 0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a (patch) | |
tree | c44e036220ea40734a00bb8e05e4afa6a9504bea /wgpu/src/layer.rs | |
parent | 87a613edd186461f1a8d224394043527a372571c (diff) | |
download | iced-0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a.tar.gz iced-0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a.tar.bz2 iced-0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a.zip |
Implement image support for `canvas` widget
Diffstat (limited to 'wgpu/src/layer.rs')
-rw-r--r-- | wgpu/src/layer.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index df289e0e..e714e281 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -114,12 +114,56 @@ 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, bounds: Rectangle, 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); |