mod matrix;
use matrix::Matrix;
pub struct Transform {
matrix: Matrix,
}
impl Transform {
pub fn new() -> Self {
Self {
matrix: matrix::identity(),
}
}
pub fn translate(mut self, x: f32, y: f32, z: f32) -> Self {
self.matrix = matrix::multiply(self.matrix, matrix::translate(x, y, z));
self
}
pub fn scale(mut self, x: f32, y: f32, z: f32) -> Self {
self.matrix = matrix::multiply(self.matrix, matrix::scale(x, y, z));
self
}
pub fn rotate(mut self, x: f32, y: f32, z: f32) -> Self {
self.matrix = matrix::multiply(self.matrix, matrix::rotate_x(x));
self.matrix = matrix::multiply(self.matrix, matrix::rotate_y(y));
self.matrix = matrix::multiply(self.matrix, matrix::rotate_z(z));
self
}
pub fn orthographic(self, width: f32, height: f32, depth: f32) -> Matrix {
matrix::multiply(self.matrix, matrix::orthographic(width, height, depth))
}
}
impl Default for Transform {
fn default() -> Self {
Transform::new()
}
}