From 87a613edd186461f1a8d224394043527a372571c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Aug 2024 16:23:30 +0200 Subject: Render text on top of images by default --- wgpu/src/layer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu/src/layer.rs') diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 9551311d..df289e0e 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -20,8 +20,8 @@ pub struct Layer { pub quads: quad::Batch, pub triangles: triangle::Batch, pub primitives: primitive::Batch, - pub text: text::Batch, pub images: image::Batch, + pub text: text::Batch, pending_meshes: Vec, pending_text: Vec, } -- cgit From 0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 03:28:43 +0200 Subject: Implement image support for `canvas` widget --- wgpu/src/layer.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'wgpu/src/layer.rs') 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 @@ -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); -- cgit From 92bd3ecd6b4a6618f0fc725dea3694c3b40e5314 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 04:30:12 +0200 Subject: Introduce `Image` struct in `core::image` --- wgpu/src/layer.rs | 51 +++++++++++---------------------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) (limited to 'wgpu/src/layer.rs') diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index e714e281..71fa0250 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -1,5 +1,6 @@ use crate::core::{ - renderer, Background, Color, Point, Radians, Rectangle, Transformation, + self, renderer, Background, Color, Point, Radians, Rectangle, + Transformation, }; use crate::graphics; use crate::graphics::color; @@ -112,29 +113,10 @@ impl Layer { self.pending_text.push(text); } - pub fn draw_image( - &mut self, - image: &Image, - transformation: Transformation, - ) { + 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::Raster(image, bounds) => { + self.draw_raster(image, bounds, transformation); } Image::Vector { handle, @@ -145,11 +127,11 @@ impl Layer { } => { self.draw_svg( handle.clone(), - *color, - *bounds, + color, + bounds, transformation, - *rotation, - *opacity, + rotation, + opacity, ); } } @@ -157,22 +139,11 @@ impl Layer { pub fn draw_raster( &mut self, - handle: crate::core::image::Handle, - filter_method: crate::core::image::FilterMethod, + image: core::Image, bounds: Rectangle, transformation: Transformation, - rotation: Radians, - opacity: f32, - snap: bool, ) { - let image = Image::Raster { - handle, - filter_method, - bounds: bounds * transformation, - rotation, - opacity, - snap, - }; + let image = Image::Raster(image, bounds * transformation); self.images.push(image); } -- cgit From d4b08462e5a25929ec4df32f242898986902af56 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 04:52:55 +0200 Subject: Introduce `Svg` struct in `core::svg` --- wgpu/src/layer.rs | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) (limited to 'wgpu/src/layer.rs') diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 71fa0250..68d5a015 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -1,6 +1,5 @@ use crate::core::{ - self, renderer, Background, Color, Point, Radians, Rectangle, - Transformation, + self, renderer, Background, Color, Point, Rectangle, Svg, Transformation, }; use crate::graphics; use crate::graphics::color; @@ -118,21 +117,8 @@ impl Layer { Image::Raster(image, bounds) => { self.draw_raster(image, bounds, transformation); } - Image::Vector { - handle, - color, - bounds, - rotation, - opacity, - } => { - self.draw_svg( - handle.clone(), - color, - bounds, - transformation, - rotation, - opacity, - ); + Image::Vector(svg, bounds) => { + self.draw_svg(svg, bounds, transformation); } } } @@ -150,20 +136,11 @@ impl Layer { pub fn draw_svg( &mut self, - handle: crate::core::svg::Handle, - color: Option, + svg: Svg, bounds: Rectangle, transformation: Transformation, - rotation: Radians, - opacity: f32, ) { - let svg = Image::Vector { - handle, - color, - bounds: bounds * transformation, - rotation, - opacity, - }; + let svg = Image::Vector(svg, bounds * transformation); self.images.push(svg); } -- cgit