| 1 | use approxrust-analyzer cargo approx 0.5.1 crate/::AbsDiffEqrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#; |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/::Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#; |
| 3 | |
| 4 | /// Methods to tell the tell about the visual characteristics of the color |
| 5 | pub trait VisualColorrust-analyzer cargo palette 0.7.6 visual/VisualColor#<T> |
| 6 | where |
| 7 | 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>, |
| 8 | { |
| 9 | /// Returns `true`, if the color is grey within the bounds of `epsilon`-tolerance, |
| 10 | /// i.e. visually only the luminance value matters, not the color's hue. |
| 11 | fn is_greyrust-analyzer cargo palette 0.7.6 visual/VisualColor#is_grey().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool; |
| 12 | |
| 13 | /// Returns `true`, if the color is white within the bounds of `epsilon`-tolerance, |
| 14 | /// i.e. the color's hue is irrelevant **and** it is at or beyond the |
| 15 | /// `sRGB` maximum brightness. |
| 16 | /// A color that is *only* at or beyond maximum brightness isn't |
| 17 | /// necessarily white. It may also be a bright shining hue. |
| 18 | fn is_whiterust-analyzer cargo palette 0.7.6 visual/VisualColor#is_white().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool; |
| 19 | |
| 20 | /// Returns `true`, if the color is black within the bounds of `epsilon`-tolerance. |
| 21 | fn is_blackrust-analyzer cargo palette 0.7.6 visual/VisualColor#is_black().(&self, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool; |
| 22 | } |
| 23 | |
| 24 | /// Methods to compare visual characteristics of two colors |
| 25 | pub trait VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#<O, S, T>: VisualColorrust-analyzer cargo palette 0.7.6 visual/VisualColor#<T> |
| 26 | where |
| 27 | 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> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 28 | S: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Self>, |
| 29 | O: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Self>, |
| 30 | { |
| 31 | /// Returns true, if `self` and `other` are either both white or both black |
| 32 | fn both_black_or_both_whiterust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#both_black_or_both_white().(s: S, o: O, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 33 | s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().is_whiterust-analyzer cargo palette 0.7.6 visual/VisualColor#is_white().(epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) && o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().is_whiterust-analyzer cargo palette 0.7.6 visual/VisualColor#is_white().(epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 34 | || s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().is_blackrust-analyzer cargo palette 0.7.6 visual/VisualColor#is_black().(epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) && o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().is_blackrust-analyzer cargo palette 0.7.6 visual/VisualColor#is_black().(epsilon) |
| 35 | } |
| 36 | |
| 37 | /// Returns true, if `self` and `other` are both fully desaturated |
| 38 | fn both_greyscalerust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#both_greyscale().(s: S, o: O, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool { |
| 39 | s.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().is_greyrust-analyzer cargo palette 0.7.6 visual/VisualColor#is_grey().(epsilon.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) && o.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().is_greyrust-analyzer cargo palette 0.7.6 visual/VisualColor#is_grey().(epsilon) |
| 40 | } |
| 41 | fn visually_eqrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#visually_eq().(s: S, o: O, epsilon: T::Epsilonrust-analyzer cargo approx 0.5.1 abs_diff_eq/AbsDiffEq#Epsilon#) -> bool; |
| 42 | } |