summaryrefslogtreecommitdiffstats
path: root/graphics/src/transformation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/transformation.rs')
-rw-r--r--graphics/src/transformation.rs59
1 files changed, 0 insertions, 59 deletions
diff --git a/graphics/src/transformation.rs b/graphics/src/transformation.rs
deleted file mode 100644
index cf0457a4..00000000
--- a/graphics/src/transformation.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-use glam::{Mat4, Vec3};
-use std::ops::Mul;
-
-/// A 2D transformation matrix.
-#[derive(Debug, Clone, Copy, PartialEq)]
-pub struct Transformation(Mat4);
-
-impl Transformation {
- /// Get the identity transformation.
- pub fn identity() -> Transformation {
- Transformation(Mat4::IDENTITY)
- }
-
- /// Creates an orthographic projection.
- #[rustfmt::skip]
- pub fn orthographic(width: u32, height: u32) -> Transformation {
- Transformation(Mat4::orthographic_rh_gl(
- 0.0, width as f32,
- height as f32, 0.0,
- -1.0, 1.0
- ))
- }
-
- /// Creates a translate transformation.
- pub fn translate(x: f32, y: f32) -> 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)))
- }
-}
-
-impl Mul for Transformation {
- type Output = Self;
-
- fn mul(self, rhs: Self) -> Self {
- Transformation(self.0 * rhs.0)
- }
-}
-
-impl AsRef<[f32; 16]> for Transformation {
- fn as_ref(&self) -> &[f32; 16] {
- self.0.as_ref()
- }
-}
-
-impl From<Transformation> for [f32; 16] {
- fn from(t: Transformation) -> [f32; 16] {
- *t.as_ref()
- }
-}
-
-impl From<Transformation> for Mat4 {
- fn from(transformation: Transformation) -> Self {
- transformation.0
- }
-}