Skip to content

Commit

Permalink
Merge #200
Browse files Browse the repository at this point in the history
200: Add Oklab support r=Ogeon a=arzg

Oklab assumes the D65 colour space. In my first attempt at implementing this, the `Oklab` struct didn’t have a `Wp` parameter. This caused all `FromColorUnclamped` derives to not compile, so I added the parameter back with comments warning about how it doesn’t have any effect. Ideally this wouldn’t be needed.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
  • Loading branch information
bors[bot] and lunacookies committed Jun 25, 2021
2 parents 121959c + b1256f4 commit 7223627
Show file tree
Hide file tree
Showing 9 changed files with 1,600 additions and 9 deletions.
5 changes: 3 additions & 2 deletions palette/src/equality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use crate::float::Float;
use crate::white_point::WhitePoint;
use crate::{
from_f64, FloatComponent, FromF64, Hsluv, Lab, LabHue, Lch, Lchuv, Luv, LuvHue, RgbHue, Xyz,
Yxy,
from_f64, FloatComponent, FromF64, Hsluv, Lab, LabHue, Lch, Lchuv, Luv, LuvHue, OklabHue,
RgbHue, Xyz, Yxy,
};

macro_rules! impl_eq {
Expand Down Expand Up @@ -153,3 +153,4 @@ macro_rules! impl_eq_hue {
impl_eq_hue!(LabHue);
impl_eq_hue!(RgbHue);
impl_eq_hue!(LuvHue);
impl_eq_hue!(OklabHue);
6 changes: 6 additions & 0 deletions palette/src/hues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ make_hues! {
/// It's measured in degrees and uses the three additive primaries _red_,
/// _green_ and _blue_.
struct RgbHue;

/// A hue type for the Oklab color space.
///
/// It's measured in degrees.
struct OklabHue;
}

#[inline]
Expand Down Expand Up @@ -375,6 +380,7 @@ macro_rules! impl_uniform {
impl_uniform!(UniformLabHue, LabHue);
impl_uniform!(UniformRgbHue, RgbHue);
impl_uniform!(UniformLuvHue, LuvHue);
impl_uniform!(UniformOklabHue, OklabHue);

#[cfg(test)]
mod test {
Expand Down
6 changes: 5 additions & 1 deletion palette/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ pub use lch::{Lch, Lcha};
pub use lchuv::{Lchuv, Lchuva};
pub use luma::{GammaLuma, GammaLumaa, LinLuma, LinLumaa, SrgbLuma, SrgbLumaa};
pub use luv::{Luv, Luva};
pub use oklab::{Oklab, Oklaba};
pub use oklch::{Oklch, Oklcha};
pub use rgb::{GammaSrgb, GammaSrgba, LinSrgb, LinSrgba, Packed, RgbChannels, Srgb, Srgba};
pub use xyz::{Xyz, Xyza};
pub use yxy::{Yxy, Yxya};
Expand All @@ -254,7 +256,7 @@ pub use color_difference::ColorDifference;
pub use component::*;
pub use convert::{FromColor, IntoColor};
pub use encoding::pixel::Pixel;
pub use hues::{LabHue, LuvHue, RgbHue};
pub use hues::{LabHue, LuvHue, OklabHue, RgbHue};
pub use matrix::Mat3;
pub use relative_contrast::{contrast_ratio, RelativeContrast};

Expand Down Expand Up @@ -432,6 +434,8 @@ mod lch;
mod lchuv;
pub mod luma;
mod luv;
mod oklab;
mod oklch;
pub mod rgb;
mod xyz;
mod yxy;
Expand Down

0 comments on commit 7223627

Please sign in to comment.