| 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#, Okhslrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#, 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 Okhslrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#<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 `saturation == 0` |
| 21 | fn is_greyrust-analyzer cargo palette 0.7.6 okhsl/visual_eq/impl#[`Okhsl<T>`][`VisualColor<T>`]is_grey().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 22 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.saturationrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#saturation. >= -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 23 | self.saturationrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#saturation..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 `Self::is_grey` && `lightness >= 1`, |
| 27 | /// i.e. the color's hue is irrelevant **and** it is at or beyond the |
| 28 | /// `sRGB` maximum luminance. A color at or beyond maximum brightness isn't |
| 29 | /// necessarily white. It may also be a bright shining hue. |
| 30 | fn is_whiterust-analyzer cargo palette 0.7.6 okhsl/visual_eq/impl#[`Okhsl<T>`][`VisualColor<T>`]is_white().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 31 | self.is_greyrust-analyzer cargo palette 0.7.6 okhsl/visual_eq/impl#[`Okhsl<T>`][`VisualColor<T>`]is_grey().(epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) && self.lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().T::onerust-analyzer cargo palette 0.7.6 num/One#one().() |
| 32 | || self.lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness..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 okhsl/visual_eq/impl#[`Okhsl<T>`][`VisualColor<T>`]is_black().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 37 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness. >= -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 38 | self.lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().epsilon |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | impl<S, O, T> VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#<O, S, T> for Okhslrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#<T> |
| 43 | where |
| 44 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# |
| 45 | + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 46 | + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# |
| 47 | + SignedAnglerust-analyzer cargo palette 0.7.6 angle/SignedAngle# |
| 48 | + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 49 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 50 | + AngleEqrust-analyzer cargo palette 0.7.6 angle/AngleEq#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 51 | + 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> |
| 52 | + AbsDiffEqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#<Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon# = T> |
| 53 | + 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> |
| 54 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 55 | 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#>, |
| 56 | S: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Selfrust-analyzer cargo palette 0.7.6 okhsl/visual_eq/impl#[`Okhsl<T>`][`VisuallyEqual<O, S, T>`]> + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 57 | O: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Selfrust-analyzer cargo palette 0.7.6 okhsl/visual_eq/impl#[`Okhsl<T>`][`VisuallyEqual<O, S, T>`]> + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 58 | { |
| 59 | fn visually_eqrust-analyzer cargo palette 0.7.6 okhsl/visual_eq/impl#[`Okhsl<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 { |
| 60 | 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().()) |
| 61 | || VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#::both_greyscalerust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#both_greyscale().(s, o, 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().() |
| 63 | .lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness. |
| 64 | .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().().lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness., epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 65 | || s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().huerust-analyzer cargo palette 0.7.6 okhsl/Okhsl#hue..abs_diff_eqrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`][`AbsDiffEq<Self>`]abs_diff_eq().(&o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().huerust-analyzer cargo palette 0.7.6 okhsl/Okhsl#hue., epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 66 | && s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().() |
| 67 | .saturationrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#saturation. |
| 68 | .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().().saturationrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#saturation., epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 69 | && s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().() |
| 70 | .lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness. |
| 71 | .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().().lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness., epsilon) |
| 72 | } |
| 73 | } |