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` --- tiny_skia/src/geometry.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index ced5b408..1df5aa18 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -154,11 +154,15 @@ impl Frame { .pre_concat(tiny_skia::Transform::from_rotate(angle.to_degrees())); } - 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 }); } - pub fn scale_nonuniform(&mut self, scale: Vector) { + pub fn scale_nonuniform(&mut self, scale: impl Into) { + let scale = scale.into(); + self.transform = self.transform.pre_scale(scale.x, scale.y); } -- cgit