Merge pull request #2070 from ripytide/master

Added a Frame::scale_nonuniform method
This commit is contained in:
Héctor Ramón 2023-09-07 06:03:41 +02:00 committed by GitHub
commit b5e7fb240c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 12 deletions

View file

@ -444,11 +444,21 @@ 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) {
pub fn scale(&mut self, scale: impl Into<f32>) {
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: impl Into<Vector>) {
let scale = scale.into();
self.transforms.current.raw =
self.transforms.current.raw.pre_scale(scale, scale);
self.transforms.current.raw.pre_scale(scale.x, scale.y);
self.transforms.current.is_identity = false;
}