microcad_lang/value/
matrix.rs1use crate::ty::*;
7
8#[derive(Debug, Clone, PartialEq)]
10pub enum Matrix {
11 Matrix2(microcad_core::Mat2),
13 Matrix3(microcad_core::Mat3),
15 Matrix4(microcad_core::Mat4),
17}
18
19impl Ty for Matrix {
20 fn ty(&self) -> Type {
21 match self {
22 Matrix::Matrix2(_) => Type::Matrix(MatrixType::new(2, 2)),
23 Matrix::Matrix3(_) => Type::Matrix(MatrixType::new(3, 3)),
24 Matrix::Matrix4(_) => Type::Matrix(MatrixType::new(4, 4)),
25 }
26 }
27}
28
29impl std::fmt::Display for Matrix {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 match self {
32 Matrix::Matrix2(matrix2) => write!(f, "{matrix2:?}"),
33 Matrix::Matrix3(matrix3) => write!(f, "{matrix3:?}"),
34 Matrix::Matrix4(matrix4) => write!(f, "{matrix4:?}"),
35 }
36 }
37}