Reorganise sRGB module a little
This commit is contained in:
1 parent
92b521ea9a
commit
c5f64b757f
1 file changed
+25
-13
+25
-13
@@ -2,6 +2,13 @@ use super::*;
|
||||
|
||||
use ccvl_proc_macros::Pixel;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pixel)]
|
||||
pub struct SRGB {
|
||||
pub r: f32,
|
||||
pub g: f32,
|
||||
pub b: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pixel)]
|
||||
pub struct SRGBA {
|
||||
pub r: f32,
|
||||
@@ -10,13 +17,6 @@ pub struct SRGBA {
|
||||
pub a: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pixel)]
|
||||
pub struct SRGB {
|
||||
pub r: f32,
|
||||
pub g: f32,
|
||||
pub b: f32,
|
||||
}
|
||||
|
||||
const CUTOFF: f32 = 4.05e-2;
|
||||
const LINEAR_DIVISOR: f32 = 12.92;
|
||||
const SHIFT: f32 = 5.5e-2;
|
||||
@@ -46,12 +46,6 @@ impl SRGBA {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<SRGB> for SRGBA {
|
||||
fn into(self) -> SRGB {
|
||||
SRGB::new(self.r, self.g, self.b)
|
||||
}
|
||||
}
|
||||
|
||||
impl SRGB {
|
||||
pub fn new(r: f32, g: f32, b: f32) -> Self {
|
||||
Self { r, g, b }
|
||||
@@ -64,6 +58,12 @@ impl Into<SRGBA> for SRGB {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SRGBA> for SRGB {
|
||||
fn from(rgba: SRGBA) -> Self {
|
||||
Self::new(rgba.r, rgba.g, rgba.b)
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<LinearRGB> for SRGB {
|
||||
fn into(self) -> LinearRGB {
|
||||
LinearRGB::new(
|
||||
@@ -84,6 +84,18 @@ impl From<LinearRGB> for SRGB {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<LinearRGB> for SRGBA {
|
||||
fn into(self) -> LinearRGB {
|
||||
SRGB::from(self).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LinearRGB> for SRGBA {
|
||||
fn from(linear: LinearRGB) -> Self {
|
||||
SRGB::from(linear).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user