Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Oklab support #200

Merged
merged 2 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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