65 lines
1.2 KiB
Rust
65 lines
1.2 KiB
Rust
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub struct LinearRGB {
|
|
pub r: f32,
|
|
pub g: f32,
|
|
pub b: f32,
|
|
}
|
|
|
|
impl LinearRGB {
|
|
pub fn new(r: f32, g: f32, b: f32) -> Self {
|
|
Self { r, g, b }
|
|
}
|
|
}
|
|
|
|
impl std::ops::AddAssign for LinearRGB {
|
|
fn add_assign(&mut self, other: LinearRGB) {
|
|
self.r += other.r;
|
|
self.g += other.g;
|
|
self.b += other.b;
|
|
}
|
|
}
|
|
|
|
impl std::ops::MulAssign<f32> for LinearRGB {
|
|
fn mul_assign(&mut self, scalar: f32) {
|
|
self.r *= scalar;
|
|
self.g *= scalar;
|
|
self.b *= scalar;
|
|
}
|
|
}
|
|
|
|
impl std::ops::DivAssign<f32> for LinearRGB {
|
|
fn div_assign(&mut self, scalar: f32) {
|
|
self.r /= scalar;
|
|
self.g /= scalar;
|
|
self.b /= scalar;
|
|
}
|
|
}
|
|
|
|
impl std::ops::Mul<f32> for LinearRGB {
|
|
type Output = Self;
|
|
|
|
fn mul(mut self, scalar: f32) -> Self {
|
|
self *= scalar;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl std::ops::Div<f32> for LinearRGB {
|
|
type Output = Self;
|
|
|
|
fn div(mut self, scalar: f32) -> Self {
|
|
self /= scalar;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl std::default::Default for LinearRGB {
|
|
fn default() -> Self {
|
|
Self {
|
|
r: 0.0,
|
|
g: 0.0,
|
|
b: 0.0,
|
|
}
|
|
}
|
|
}
|