From 5371fae21a4c1110a37e7183e794cba234598d9c Mon Sep 17 00:00:00 2001 From: ripytide Date: Tue, 5 Sep 2023 10:49:50 +0100 Subject: added a Frame::scale_nonuniform method --- wgpu/src/geometry.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'wgpu/src/geometry.rs') diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index e421e0b0..2cd07a27 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -444,7 +444,7 @@ impl Frame { self.transforms.current.is_identity = false; } - /// Applies a scaling to the current transform of the [`Frame`]. + /// Applies a uniform scaling to the current transform of the [`Frame`]. #[inline] pub fn scale(&mut self, scale: f32) { self.transforms.current.raw = @@ -452,6 +452,14 @@ impl Frame { self.transforms.current.is_identity = false; } + /// Applies a non-uniform scaling to the current transform of the [`Frame`]. + #[inline] + pub fn scale_nonuniform(&mut self, scale: Vector) { + self.transforms.current.raw = + self.transforms.current.raw.pre_scale(scale.x, scale.y); + self.transforms.current.is_identity = false; + } + /// Produces the [`Primitive`] representing everything drawn on the [`Frame`]. pub fn into_primitive(self) -> Primitive { Primitive::Group { -- cgit From 1f263051b6c2d2f2a02633d8a6277c772ae8e7f9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 7 Sep 2023 05:45:51 +0200 Subject: Implement `scale` in terms of `scale_nonuniform` --- wgpu/src/geometry.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'wgpu/src/geometry.rs') diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 2cd07a27..64b98469 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -447,9 +447,7 @@ impl Frame { /// Applies a uniform scaling to the current transform of the [`Frame`]. #[inline] pub fn scale(&mut self, scale: f32) { - self.transforms.current.raw = - self.transforms.current.raw.pre_scale(scale, scale); - self.transforms.current.is_identity = false; + self.scale_nonuniform(Vector { x: scale, y: scale }); } /// Applies a non-uniform scaling to the current transform of the [`Frame`]. -- cgit From 09965b686ea6bf82e6c13ed5331bbeb059848e4f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 7 Sep 2023 05:51:39 +0200 Subject: Make `scale` methods in `Frame` generic over `f32` and `Vector` --- wgpu/src/geometry.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'wgpu/src/geometry.rs') diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 64b98469..c3e16f8c 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -446,13 +446,17 @@ impl Frame { /// Applies a uniform scaling to the current transform of the [`Frame`]. #[inline] - pub fn scale(&mut self, scale: f32) { + pub fn scale(&mut self, scale: impl Into) { + let scale = scale.into(); + self.scale_nonuniform(Vector { x: scale, y: scale }); } /// Applies a non-uniform scaling to the current transform of the [`Frame`]. #[inline] - pub fn scale_nonuniform(&mut self, scale: Vector) { + pub fn scale_nonuniform(&mut self, scale: impl Into) { + let scale = scale.into(); + self.transforms.current.raw = self.transforms.current.raw.pre_scale(scale.x, scale.y); self.transforms.current.is_identity = false; -- cgit From 89d9f1d7d2202029028a487df1dd11b0665a7517 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Sat, 9 Sep 2023 12:24:47 +0200 Subject: Fix majority of unresolved documentation links --- wgpu/src/geometry.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'wgpu/src/geometry.rs') diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index c3e16f8c..63a59c05 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -310,13 +310,11 @@ impl Frame { /// resulting glyphs will not be rotated or scaled properly. /// /// Additionally, all text will be rendered on top of all the layers of - /// a [`Canvas`]. Therefore, it is currently only meant to be used for + /// a `Canvas`. Therefore, it is currently only meant to be used for /// overlays, which is the most common use case. /// /// Support for vectorial text is planned, and should address all these /// limitations. - /// - /// [`Canvas`]: crate::widget::Canvas pub fn fill_text(&mut self, text: impl Into) { let text = text.into(); -- cgit From 34f07b60273d6cfe13834af54cd0e24d34569387 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 04:11:52 +0200 Subject: Fix `clippy::semicolon_if_nothing_returned` --- wgpu/src/geometry.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wgpu/src/geometry.rs') diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 63a59c05..655362b7 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -480,7 +480,7 @@ impl Frame { }, size: self.size, }), - )) + )); } } Buffer::Gradient(buffer) => { @@ -493,7 +493,7 @@ impl Frame { }, size: self.size, }), - )) + )); } } } -- cgit