use crate::core::matrix::Matrix;
#[repr(u8)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
pub enum EncodedOrigin {
#[default]
TopLeft = 1,
TopRight = 2,
BottomRight = 3,
BottomLeft = 4,
LeftTop = 5,
RightTop = 6,
RightBottom = 7,
LeftBottom = 8,
}
impl EncodedOrigin {
#[must_use]
#[inline]
pub const fn to_matrix(self, w: i32, h: i32) -> Matrix {
match self {
Self::TopLeft => Matrix::identity(),
Self::TopRight => Matrix::from_i32(-1, 0, w, 0, 1, 0, 0, 0, 1),
Self::BottomRight => Matrix::from_i32(-1, 0, w, 0, -1, h, 0, 0, 1),
Self::BottomLeft => Matrix::from_i32(1, 0, 0, 0, -1, h, 0, 0, 1),
Self::LeftTop => Matrix::from_i32(0, 1, 0, 1, 0, 0, 0, 0, 1),
Self::RightTop => Matrix::from_i32(0, -1, w, 1, 0, 0, 0, 0, 1),
Self::RightBottom => Matrix::from_i32(0, -1, w, -1, 0, h, 0, 0, 1),
Self::LeftBottom => Matrix::from_i32(0, 1, 0, -1, 0, h, 0, 0, 1),
}
}
#[must_use]
#[inline]
pub fn swaps_width_height(self) -> bool {
self >= Self::LeftTop
}
}