| 1 | use craterust-analyzer cargo palette 0.7.6 crate/::anglerust-analyzer cargo palette 0.7.6 angle/::{AngleEqrust-analyzer cargo palette 0.7.6 angle/AngleEq#, HalfRotationrust-analyzer cargo palette 0.7.6 angle/HalfRotation#, RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#, SignedAnglerust-analyzer cargo palette 0.7.6 angle/SignedAngle#}; |
| 2 | use craterust-analyzer cargo palette 0.7.6 crate/::numrust-analyzer cargo palette 0.7.6 num/::{Onerust-analyzer cargo palette 0.7.6 num/One#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#}; |
| 3 | use craterust-analyzer cargo palette 0.7.6 crate/::visualrust-analyzer cargo palette 0.7.6 visual/::{VisualColorrust-analyzer cargo palette 0.7.6 visual/VisualColor#, VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#}; |
| 4 | use craterust-analyzer cargo palette 0.7.6 crate/::{HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#}; |
| 5 | use approxrust-analyzer cargo approx 0.5.1 crate/::AbsDiffEqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#, Negrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#, Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#}; |
| 8 | |
| 9 | impl<T> VisualColorrust-analyzer cargo palette 0.7.6 visual/VisualColor#<T> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T> |
| 10 | where |
| 11 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# |
| 12 | + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 13 | + AbsDiffEqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#<Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon# = T> |
| 14 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 15 | + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 16 | + Negrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#Output# = T>, |
| 17 | T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 18 | OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>: AbsDiffEqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#<Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon# = T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#>, |
| 19 | { |
| 20 | /// Returns true, if `chroma == 0` |
| 21 | #[allow(dead_code)] |
| 22 | fn is_greyrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisualColor<T>`]is_grey().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 23 | self.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) && self.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), epsilon) |
| 24 | } |
| 25 | |
| 26 | /// Returns true, if `lightness >= 1` |
| 27 | /// |
| 28 | /// **Note:** `sRGB` to `Oklab` conversion uses `f32` constants. |
| 29 | /// A tolerance `epsilon >= 1e-8` is required to reliably detect white. |
| 30 | /// Conversion of `sRGB` via XYZ requires `epsilon >= 1e-5` |
| 31 | fn is_whiterust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisualColor<T>`]is_white().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 32 | self.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().T::onerust-analyzer cargo palette 0.7.6 num/One#one().() || self.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().(), epsilon) |
| 33 | } |
| 34 | |
| 35 | /// Returns true, if `lightness == 0` |
| 36 | fn is_blackrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisualColor<T>`]is_black().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 37 | self.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), epsilon) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | impl<S, O, T> VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#<O, S, T> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T> |
| 42 | where |
| 43 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# |
| 44 | + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 45 | + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# |
| 46 | + SignedAnglerust-analyzer cargo palette 0.7.6 angle/SignedAngle# |
| 47 | + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 48 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 49 | + AngleEqrust-analyzer cargo palette 0.7.6 angle/AngleEq#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 50 | + Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#Output# = T> |
| 51 | + AbsDiffEqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#<Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon# = T> |
| 52 | + Negrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#Output# = T> |
| 53 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 54 | T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + HalfRotationrust-analyzer cargo palette 0.7.6 angle/HalfRotation# + Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#>, |
| 55 | S: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Selfrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]> + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 56 | O: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Selfrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]> + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 57 | { |
| 58 | fn visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(s: S, o: O, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 59 | VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#::both_black_or_both_whiterust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#both_black_or_both_white().(s, o, epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 60 | || s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 61 | && s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().arust-analyzer cargo palette 0.7.6 oklab/Oklab#a..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 62 | && s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().brust-analyzer cargo palette 0.7.6 oklab/Oklab#b..abs_diff_eqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#abs_diff_eq().(&o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().brust-analyzer cargo palette 0.7.6 oklab/Oklab#b., epsilon) |
| 63 | } |
| 64 | } |