Make scale methods in Frame generic over f32 and Vector

This commit is contained in:
Héctor Ramón Jiménez 2023-09-07 05:51:39 +02:00
parent 1f263051b6
commit 09965b686e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 19 additions and 11 deletions

View file

@ -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<f32>) {
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<Vector>) {
let scale = scale.into();
self.transform = self.transform.pre_scale(scale.x, scale.y);
}