use number_traits::Float;
use mat32;


pub struct InnerTransform2D<T: 'static + Sync + Send + Copy + Float> {
    pub position: [T; 2],
    pub scale: [T; 2],
    pub rotation: T,
}


impl<T: 'static + Sync + Send + Copy + Float> Default for InnerTransform2D<T> {

    #[inline(always)]
    fn default() -> Self {
        InnerTransform2D {
            position: [T::zero(); 2],
            scale: [T::one(); 2],
            rotation: T::zero(),
        }
    }
}


impl<T: 'static + Sync + Send + Copy + Float> InnerTransform2D<T> {

    #[inline(always)]
    pub fn new() -> Self {
        Self::default()
    }

    #[inline]
    pub fn matrix(&self) -> [T; 6] {
        let mut matrix = mat32::new_identity();
        mat32::compose(&mut matrix, &self.position, &self.scale, self.rotation);
        matrix
    }
}
