Allow only uniform scaling in Transformation

This commit is contained in:
Héctor Ramón Jiménez 2023-10-24 03:18:03 +02:00
parent aa41d7656e
commit a6e91d13d5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 16 additions and 21 deletions

View file

@ -26,21 +26,16 @@ impl Transformation {
Transformation(Mat4::from_translation(Vec3::new(x, y, 0.0)))
}
/// Creates a scale transformation.
pub fn scale(x: f32, y: f32) -> Transformation {
Transformation(Mat4::from_scale(Vec3::new(x, y, 1.0)))
/// Creates a uniform scaling transformation.
pub fn scale(scaling: f32) -> Transformation {
Transformation(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0)))
}
/// The scale factor on the X axis.
pub fn scale_x(&self) -> f32 {
/// The scale factor of the [`Transformation`].
pub fn scale_factor(&self) -> f32 {
self.0.x_axis.x
}
/// The scale factor on the Y axis.
pub fn scale_y(&self) -> f32 {
self.0.y_axis.y
}
/// The translation on the X axis.
pub fn translation_x(&self) -> f32 {
self.0.w_axis.x