diff options
-rw-r--r-- | renderer/src/geometry.rs | 8 | ||||
-rw-r--r-- | tiny_skia/src/geometry.rs | 4 | ||||
-rw-r--r-- | wgpu/src/geometry.rs | 10 |
3 files changed, 20 insertions, 2 deletions
diff --git a/renderer/src/geometry.rs b/renderer/src/geometry.rs index 04b5d9e6..0e524169 100644 --- a/renderer/src/geometry.rs +++ b/renderer/src/geometry.rs @@ -168,12 +168,18 @@ impl Frame { delegate!(self, frame, frame.rotate(angle)); } - /// 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) { delegate!(self, frame, frame.scale(scale)); } + /// Applies a non-uniform scaling to the current transform of the [`Frame`]. + #[inline] + pub fn scale_nonuniform(&mut self, scale: Vector) { + delegate!(self, frame, frame.scale_nonuniform(scale)); + } + pub fn into_geometry(self) -> Geometry { match self { Self::TinySkia(frame) => Geometry::TinySkia(frame.into_primitive()), diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 0fae7364..a416020f 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -158,6 +158,10 @@ impl Frame { self.transform = self.transform.pre_scale(scale, scale); } + pub fn scale_nonuniform(&mut self, scale: Vector) { + self.transform = self.transform.pre_scale(scale.x, scale.y); + } + pub fn into_primitive(self) -> Primitive { Primitive::Clip { bounds: Rectangle::new(Point::ORIGIN, self.size), 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 { |