Use Self in core::transformation
This commit is contained in:
parent
f8f2e55f19
commit
aa27ab50e5
1 changed files with 12 additions and 12 deletions
|
|
@ -13,8 +13,8 @@ impl Transformation {
|
||||||
|
|
||||||
/// Creates an orthographic projection.
|
/// Creates an orthographic projection.
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub fn orthographic(width: u32, height: u32) -> Transformation {
|
pub fn orthographic(width: u32, height: u32) -> Self{
|
||||||
Transformation(Mat4::orthographic_rh_gl(
|
Self(Mat4::orthographic_rh_gl(
|
||||||
0.0, width as f32,
|
0.0, width as f32,
|
||||||
height as f32, 0.0,
|
height as f32, 0.0,
|
||||||
-1.0, 1.0
|
-1.0, 1.0
|
||||||
|
|
@ -22,13 +22,18 @@ impl Transformation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a translate transformation.
|
/// Creates a translate transformation.
|
||||||
pub fn translate(x: f32, y: f32) -> Transformation {
|
pub fn translate(x: f32, y: f32) -> Self {
|
||||||
Transformation(Mat4::from_translation(Vec3::new(x, y, 0.0)))
|
Self(Mat4::from_translation(Vec3::new(x, y, 0.0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a uniform scaling transformation.
|
/// Creates a uniform scaling transformation.
|
||||||
pub fn scale(scaling: f32) -> Transformation {
|
pub fn scale(scaling: f32) -> Self {
|
||||||
Transformation(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0)))
|
Self(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the inverse of the [`Transformation`].
|
||||||
|
pub fn inverse(self) -> Self {
|
||||||
|
Self(self.0.inverse())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the scale factor of the [`Transformation`].
|
/// Returns the scale factor of the [`Transformation`].
|
||||||
|
|
@ -40,11 +45,6 @@ impl Transformation {
|
||||||
pub fn translation(&self) -> Vector {
|
pub fn translation(&self) -> Vector {
|
||||||
Vector::new(self.0.w_axis.x, self.0.w_axis.y)
|
Vector::new(self.0.w_axis.x, self.0.w_axis.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the inverse of the [`Transformation`].
|
|
||||||
pub fn inverse(self) -> Self {
|
|
||||||
Transformation(self.0.inverse())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Transformation {
|
impl Default for Transformation {
|
||||||
|
|
@ -57,7 +57,7 @@ impl Mul for Transformation {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn mul(self, rhs: Self) -> Self {
|
fn mul(self, rhs: Self) -> Self {
|
||||||
Transformation(self.0 * rhs.0)
|
Self(self.0 * rhs.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue