use serde::{Deserialize, Serialize};
mod matrix;
mod vector;
#[cfg(test)]
#[path = "types_tests.rs"]
mod tests;
pub use matrix::{Mat3, Mat4, Quat};
pub use vector::{Vec2, Vec3, Vec4};
#[repr(C)]
#[derive(
Clone,
Copy,
PartialEq,
Eq,
Debug,
Default,
Serialize,
Deserialize,
bytemuck::Pod,
bytemuck::Zeroable,
)]
pub struct Rgba8 {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Rgba8 {
pub const WHITE: Self = Self::new(255, 255, 255, 255);
#[must_use]
pub const fn new(r: u8, g: u8, b: u8, a: u8) -> Self {
Self { r, g, b, a }
}
#[must_use]
pub const fn opaque(r: u8, g: u8, b: u8) -> Self {
Self::new(r, g, b, 255)
}
#[must_use]
pub fn to_f32(self) -> [f32; 4] {
[
f32::from(self.r) / 255.0,
f32::from(self.g) / 255.0,
f32::from(self.b) / 255.0,
f32::from(self.a) / 255.0,
]
}
}