| 1 | //! Traits and functions used in Ok* color spaces |
| 2 | |
| 3 | #[cfg(feature = "approx")] |
| 4 | #[cfg(test)] |
| 5 | use craterust-analyzer cargo palette 0.7.6 crate/::{anglerust-analyzer cargo palette 0.7.6 angle/::RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#, numrust-analyzer cargo palette 0.7.6 num/::Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry#, OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#}; |
| 6 | |
| 7 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 8 | convertrust-analyzer cargo palette 0.7.6 convert/::IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#, |
| 9 | numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#, MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#, Onerust-analyzer cargo palette 0.7.6 num/One#, Powirust-analyzer cargo palette 0.7.6 num/Powi#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#}, |
| 10 | HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, |
| 11 | }; |
| 12 | |
| 13 | /// Finds intersection of the line defined by |
| 14 | /// |
| 15 | /// L = l0 * (1 - t) + t * l1; |
| 16 | /// |
| 17 | /// C = t * c1; |
| 18 | /// |
| 19 | /// a and b must be normalized so a² + b² == 1 |
| 20 | fn find_gamut_intersectionrust-analyzer cargo palette 0.7.6 ok_utils/find_gamut_intersection().<T>(a: T, b: T, l1: T, c1: T, l0: T, cusp: LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T>) -> T |
| 21 | where |
| 22 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Onerust-analyzer cargo palette 0.7.6 num/One# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 23 | { |
| 24 | // Find the intersection for upper and lower half separately |
| 25 | if ((l1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&l0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&cusp.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().(cusp.lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&l0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c1) 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().T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() { |
| 26 | // Lower half |
| 27 | |
| 28 | cusp.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(c1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().cusp.lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().cusp.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(l0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().l1)) |
| 29 | } else { |
| 30 | // Upper half |
| 31 | |
| 32 | // First intersect with triangle |
| 33 | let t = cusp.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(l0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().()) |
| 34 | /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(c1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(cusp.lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().cusp.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(l0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&l1)); |
| 35 | |
| 36 | // Then one step Halley's method |
| 37 | { |
| 38 | let dl = l1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&l0; |
| 39 | let dc = c1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(); |
| 40 | |
| 41 | let k_l = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3963377774) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2158037573) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b; |
| 42 | let k_m = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.1055613458) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0638541728) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b; |
| 43 | let k_s = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0894841775) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2914855480) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b; |
| 44 | |
| 45 | let l_dt = dl.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().dc.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_l; |
| 46 | let m_dt = dl.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().dc.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_m; |
| 47 | let s_dt = dl rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().dc rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_s; |
| 48 | |
| 49 | // If higher accuracy is required, 2 or 3 iterations of the following block can be used: |
| 50 | { |
| 51 | let lightness = l0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&t) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().t.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l1; |
| 52 | let chroma = t.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c1; |
| 53 | |
| 54 | let l_ = lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_l; |
| 55 | let m_ = lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_m; |
| 56 | let s_ = lightness rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().chroma rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_s; |
| 57 | |
| 58 | let l = l_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_; |
| 59 | let m = m_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m_; |
| 60 | let s = s_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_; |
| 61 | |
| 62 | let ldt = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_; |
| 63 | let mdt = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m_; |
| 64 | let sdt = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_; |
| 65 | |
| 66 | let ldt2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_; |
| 67 | let mdt2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_; |
| 68 | let sdt2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_; |
| 69 | |
| 70 | let r = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0767416621) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.3077115913) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m |
| 71 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2309699292) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s |
| 72 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().(); |
| 73 | let r1 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0767416621) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&ldt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.3077115913) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&mdt |
| 74 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2309699292) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&sdt; |
| 75 | let r2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0767416621) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&ldt2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.3077115913) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&mdt2 |
| 76 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2309699292) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&sdt2; |
| 77 | |
| 78 | let u_r = r1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(r1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().r1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().r2); |
| 79 | let mut t_r = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&u_r; |
| 80 | |
| 81 | let g = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2684380046) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.6097574011) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&m |
| 82 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3413193965) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s |
| 83 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().(); |
| 84 | let g1 = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2684380046) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&ldt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.6097574011) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&mdt |
| 85 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3413193965) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&sdt; |
| 86 | let g2 = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2684380046) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&ldt2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.6097574011) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&mdt2 |
| 87 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3413193965) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&sdt2; |
| 88 | |
| 89 | let u_g = g1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(g1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().g1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().g2); |
| 90 | let mut t_g = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&u_g; |
| 91 | |
| 92 | let b = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0041960863) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7034186147) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m |
| 93 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.7076147010) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s |
| 94 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().(); |
| 95 | let b1 = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0041960863) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().ldt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7034186147) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().mdt |
| 96 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.7076147010) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().sdt; |
| 97 | let b2 = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0041960863) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().ldt2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7034186147) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().mdt2 |
| 98 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.7076147010) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().sdt2; |
| 99 | |
| 100 | let u_b = b1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(b1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b2); |
| 101 | let mut t_b = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&u_b; |
| 102 | |
| 103 | // flt_max really is a constant, but cannot be defined as one due to the T::from_f64 function |
| 104 | let flt_max = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(10e5); |
| 105 | |
| 106 | t_r = if u_r 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::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() { |
| 107 | t_r |
| 108 | } else { |
| 109 | flt_max.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |
| 110 | }; |
| 111 | t_g = if u_g 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::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() { |
| 112 | t_g |
| 113 | } else { |
| 114 | flt_max.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |
| 115 | }; |
| 116 | t_b = if u_b 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::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() { t_b } else { flt_max }; |
| 117 | |
| 118 | t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::minrust-analyzer cargo palette 0.7.6 num/MinMax#min().(t_r, T::minrust-analyzer cargo palette 0.7.6 num/MinMax#min().(t_g, t_b)) |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | pub struct ChromaValuesrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#<T> { |
| 125 | pub zerorust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#zero.: T, |
| 126 | pub midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid.: T, |
| 127 | pub maxrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#max.: T, |
| 128 | } |
| 129 | |
| 130 | impl<T> ChromaValuesrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#<T> |
| 131 | where |
| 132 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# |
| 133 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 134 | + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 135 | + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# |
| 136 | + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# |
| 137 | + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt# |
| 138 | + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt# |
| 139 | + Powirust-analyzer cargo palette 0.7.6 num/Powi# |
| 140 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# |
| 141 | + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 142 | + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#, |
| 143 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>>, |
| 144 | { |
| 145 | // Corresponds to `get_Cs` in the reference implementation. Assumes that |
| 146 | // `lightness != 1.0` and `lightness != 0.0`. |
| 147 | pub fn from_normalizedrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ChromaValues<T>`]from_normalized().(lightness: T, a_: T, b_: T) -> Selfrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ChromaValues<T>`] { |
| 148 | let cusp = LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#::find_cusprust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]find_cusp().(a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), b_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 149 | |
| 150 | let max_chroma = find_gamut_intersectionrust-analyzer cargo palette 0.7.6 ok_utils/find_gamut_intersection().( |
| 151 | a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 152 | b_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 153 | lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 154 | T::onerust-analyzer cargo palette 0.7.6 num/One#one().(), |
| 155 | lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 156 | cusp.clonerust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`][Clone]clone().(), |
| 157 | ); |
| 158 | let st_max = STrust-analyzer cargo palette 0.7.6 ok_utils/ST#::fromrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ST<T>`][`From<LC<T>>`]from().(cusp); |
| 159 | |
| 160 | // Scale factor to compensate for the curved part of gamut shape: |
| 161 | let k = max_chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |
| 162 | /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().T::minrust-analyzer cargo palette 0.7.6 num/MinMax#min().( |
| 163 | lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().st_max.srust-analyzer cargo palette 0.7.6 ok_utils/ST#s., |
| 164 | (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&lightness) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().st_max.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t., |
| 165 | ); |
| 166 | |
| 167 | let c_mid = { |
| 168 | let st_mid = STrust-analyzer cargo palette 0.7.6 ok_utils/ST#::midrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ST<T>`]mid().(a_, b_); |
| 169 | |
| 170 | // Use a soft minimum function, instead of a sharp triangle shape to get a smooth value for chroma. |
| 171 | let c_a = lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().st_mid.srust-analyzer cargo palette 0.7.6 ok_utils/ST#s.; |
| 172 | let c_b = (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&lightness) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().st_mid.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t.; |
| 173 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.9) |
| 174 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k |
| 175 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#sqrt().(T::sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#sqrt().( |
| 176 | T::onerust-analyzer cargo palette 0.7.6 num/One#one().() |
| 177 | /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(c_a.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_a) |
| 178 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(c_b.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_b)), |
| 179 | )) |
| 180 | }; |
| 181 | |
| 182 | let c_0 = { |
| 183 | // for C_0, the shape is independent of hue, so ST are constant. |
| 184 | // Values picked to roughly be the average values of ST. |
| 185 | let c_a = lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.4); |
| 186 | let c_b = (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().lightness) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.8); |
| 187 | |
| 188 | // Use a soft minimum function, instead of a sharp triangle shape to get a smooth value for chroma. |
| 189 | T::sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#sqrt().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(c_a.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c_a) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(c_b.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c_b))) |
| 190 | }; |
| 191 | Selfrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ChromaValues<T>`] { |
| 192 | zerorust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#zero.: c_0, |
| 193 | midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid.: c_mid, |
| 194 | maxrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#max.: max_chroma, |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | /// A `lightness`-`chroma` representation of a point in the `sRGB` gamut for a fixed hue. |
| 200 | /// |
| 201 | /// Gamut is the range of representable colors of a color space. In this case the |
| 202 | /// `sRGB` color space. |
| 203 | /// |
| 204 | /// Only together are `lightness` and `chroma` guaranteed to be inside the `sRGB` gamut. |
| 205 | /// While a color with lower `chroma` will always stay in the gamut, a color of raised |
| 206 | /// *and lowered* lightness might move the point outside the gamut. |
| 207 | /// |
| 208 | ///# See |
| 209 | /// [LC diagram samples](https://bottosson.github.io/posts/gamutclipping/#gamut-clipping) |
| 210 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 211 | pub(craterust-analyzer cargo palette 0.7.6 crate/) struct LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T> { |
| 212 | /// The lightness of the color. 0 corresponds to black. 1 corresponds to white |
| 213 | pub lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness.: T, |
| 214 | /// The chroma of the color. 0 corresponds to totally desaturated (white, grey or black). |
| 215 | /// Larger values correspond to colorful values. |
| 216 | /// |
| 217 | ///Note: the maximum representable value depends on the lightness and the hue. |
| 218 | pub chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma.: T, |
| 219 | } |
| 220 | |
| 221 | /// The number of iterations used for optimizing the result of [`LC::max_saturation`]. |
| 222 | /// |
| 223 | /// Must match [`MAX_SRGB_SATURATION_INACCURACY`] |
| 224 | pub(craterust-analyzer cargo palette 0.7.6 crate/) const MAX_SRGB_SATURATION_SEARCH_MAX_ITERrust-analyzer cargo palette 0.7.6 ok_utils/MAX_SRGB_SATURATION_SEARCH_MAX_ITER.: usize = 1; |
| 225 | /// The expected inaccuracy of the result of [`LC::max_saturation`], optimized with |
| 226 | /// [`MAX_SRGB_SATURATION_SEARCH_MAX_ITER`] iterations |
| 227 | pub(craterust-analyzer cargo palette 0.7.6 crate/) const MAX_SRGB_SATURATION_INACCURACYrust-analyzer cargo palette 0.7.6 ok_utils/MAX_SRGB_SATURATION_INACCURACY.: f64 = 1e-6; |
| 228 | |
| 229 | impl<T> LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T> |
| 230 | where |
| 231 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Onerust-analyzer cargo palette 0.7.6 num/One# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Powirust-analyzer cargo palette 0.7.6 num/Powi# + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 232 | { |
| 233 | /// Returns the cusp of the geometrical shape of representable `sRGB` colors for |
| 234 | /// normalized `a` and `b` values of an `OKlabHue`, where "normalized" means, `a² + b² == 1`. |
| 235 | /// |
| 236 | /// The cusp solely depends on the maximum saturation of the hue, but is expressed as a |
| 237 | /// combination of lightness and chroma. |
| 238 | pub fn find_cusprust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]find_cusp().(a: T, b: T) -> Selfrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`] |
| 239 | where |
| 240 | T: MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#, |
| 241 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>>, |
| 242 | { |
| 243 | // First, find the maximum saturation (saturation S = C/L) |
| 244 | let max_saturation = Selfrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]::max_saturationrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]max_saturation().(a.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), b.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 245 | // Convert to linear sRGB to find the first point where at least one of r,g or b >= 1: |
| 246 | let rgb_at_max: LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T> = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().( |
| 247 | T::onerust-analyzer cargo palette 0.7.6 num/One#one().(), |
| 248 | max_saturation.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a, |
| 249 | max_saturation.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b, |
| 250 | ) |
| 251 | .into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#into_color_unclamped().(); |
| 252 | |
| 253 | let max_lightness = |
| 254 | T::cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().T::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(rgb_at_max.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., rgb_at_max.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.), rgb_at_max.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.)); |
| 255 | Selfrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`] { |
| 256 | lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness.: max_lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 257 | chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma.: max_lightness rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().max_saturation, |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | /// Returns the maximum `sRGB`-saturation (chroma / lightness) for the hue (`a` and `b`). |
| 262 | /// |
| 263 | /// # Arguments |
| 264 | /// * `a` - the green/redness of the hue |
| 265 | /// * `b` - the blue/yellowness of the hue |
| 266 | /// |
| 267 | /// `a` and `b` must be normalized to a chroma (`a²+b²`) of `1`. |
| 268 | /// # See |
| 269 | /// [Original C-Version](https://bottosson.github.io/posts/gamutclipping/#intersection-with-srgb-gamut) |
| 270 | fn max_saturationrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]max_saturation().(a: T, b: T) -> T { |
| 271 | // Max saturation will be reached, when one of r, g or b goes below zero. |
| 272 | // Select different coefficients depending on which component goes below zero first |
| 273 | // wl, wm and ws are coefficients for https://en.wikipedia.org/wiki/LMS_color_space |
| 274 | // -- the color space modelling human perception. |
| 275 | let (k0, k1, k2, k3, k4, wl, wm, ws) = |
| 276 | if T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.88170328) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.80936493) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b 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().() { |
| 277 | // red component at zero first |
| 278 | ( |
| 279 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.19086277), |
| 280 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.76576728), |
| 281 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.59662641), |
| 282 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.75515197), |
| 283 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.56771245), |
| 284 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0767416621), |
| 285 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.3077115913), |
| 286 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2309699292), |
| 287 | ) |
| 288 | } else if T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.81444104) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.19445276) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b 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().() { |
| 289 | //green component at zero first |
| 290 | ( |
| 291 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.73956515), |
| 292 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.45954404), |
| 293 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.08285427), |
| 294 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.12541070), |
| 295 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.14503204), |
| 296 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.2684380046), |
| 297 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.6097574011), |
| 298 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.3413193965), |
| 299 | ) |
| 300 | } else { |
| 301 | //blue component at zero first |
| 302 | ( |
| 303 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.35733652), |
| 304 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.00915799), |
| 305 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.15130210), |
| 306 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.50559606), |
| 307 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.00692167), |
| 308 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.0041960863), |
| 309 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.7034186147), |
| 310 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.7076147010), |
| 311 | ) |
| 312 | }; |
| 313 | |
| 314 | // Approximate max saturation using a polynomial |
| 315 | let mut approx_max_saturation = |
| 316 | k0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().k1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().k2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().k3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().k4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b; |
| 317 | // Get closer with Halley's method |
| 318 | let k_l = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3963377774) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2158037573) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b; |
| 319 | let k_m = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.1055613458) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0638541728) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b; |
| 320 | let k_s = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.0894841775) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2914855480) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b; |
| 321 | |
| 322 | for _i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#MAX_SRGB_SATURATION_SEARCH_MAX_ITERrust-analyzer cargo palette 0.7.6 ok_utils/MAX_SRGB_SATURATION_SEARCH_MAX_ITER. { |
| 323 | let l_ = T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().approx_max_saturation.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_l; |
| 324 | let m_ = T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().approx_max_saturation.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_m; |
| 325 | let s_ = T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().approx_max_saturation.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_s; |
| 326 | |
| 327 | let l = l_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3); |
| 328 | let m = m_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3); |
| 329 | let s = s_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3); |
| 330 | |
| 331 | // first derivative components |
| 332 | let l_ds = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2); |
| 333 | let m_ds = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_m rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2); |
| 334 | let s_ds = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k_s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2); |
| 335 | |
| 336 | // second derivative components |
| 337 | let l_ds2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_l.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_; |
| 338 | let m_ds2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_m.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_; |
| 339 | let s_ds2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_s.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_; |
| 340 | |
| 341 | // let x be the approximate maximum saturation and |
| 342 | // i the current iteration |
| 343 | // f = f(x_i), f1 = f'(x_i), f2 = f''(x_i) for |
| 344 | let f = wl.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().wm.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().ws.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s; |
| 345 | let f1 = wl.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_ds rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().wm.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_ds rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().ws.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_ds; |
| 346 | let f2 = wl.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_ds2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().wm.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_ds2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().ws.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_ds2; |
| 347 | |
| 348 | approx_max_saturation = |
| 349 | approx_max_saturation rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().f.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&f1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(f1.powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().f rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().f2); |
| 350 | } |
| 351 | approx_max_saturation |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | #[cfg(feature = "approx")] |
| 356 | #[cfg(test)] |
| 357 | impl<T> OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T> |
| 358 | where |
| 359 | T: RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# |
| 360 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 361 | + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# |
| 362 | + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry# |
| 363 | + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# |
| 364 | + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt# |
| 365 | + Powirust-analyzer cargo palette 0.7.6 num/Powi# |
| 366 | + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 367 | + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# |
| 368 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 369 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>>, |
| 370 | { |
| 371 | pub(craterust-analyzer cargo palette 0.7.6 crate/) fn srgb_limitsrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`OklabHue<T>`]srgb_limits().(self) -> (LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T>, T, T) { |
| 372 | let normalized_hue_vector = self.into_cartesianrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]into_cartesian().(); |
| 373 | let lc = LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#::find_cusprust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]find_cusp().( |
| 374 | normalized_hue_vector.0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 375 | normalized_hue_vector.1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 376 | ); |
| 377 | let a = lc.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().normalized_hue_vector.0; |
| 378 | let b = lc.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().normalized_hue_vector.1; |
| 379 | (lc, a, b) |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | /// A representation of [`LC`], that allows computing the maximum chroma `C` |
| 384 | /// for a given lightness `L` in the gamut triangle of a hue as |
| 385 | /// ```text |
| 386 | /// C |
| 387 | /// = min(S*L, T*(1-L)) |
| 388 | /// = min(lc.chroma / lc.lightness * L, lc.chroma / (T::one() - lc.lightness) * (1-L)) |
| 389 | /// ``` |
| 390 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 391 | pub(craterust-analyzer cargo palette 0.7.6 crate/) struct STrust-analyzer cargo palette 0.7.6 ok_utils/ST#<T> { |
| 392 | /// `lc.chroma / lc.lightness` |
| 393 | pub srust-analyzer cargo palette 0.7.6 ok_utils/ST#s.: T, |
| 394 | /// `lc.chroma / (T::one() - lc.lightness)` |
| 395 | pub trust-analyzer cargo palette 0.7.6 ok_utils/ST#t.: T, |
| 396 | } |
| 397 | |
| 398 | impl<T> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T>> for STrust-analyzer cargo palette 0.7.6 ok_utils/ST#<T> |
| 399 | where |
| 400 | T: Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Onerust-analyzer cargo palette 0.7.6 num/One# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 401 | { |
| 402 | fn fromrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ST<T>`][`From<LC<T>>`]from().(lc: LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T>) -> Selfrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ST<T>`][`From<LC<T>>`] { |
| 403 | STrust-analyzer cargo palette 0.7.6 ok_utils/ST# { |
| 404 | srust-analyzer cargo palette 0.7.6 ok_utils/ST#s.: lc.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().&lc.lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness., |
| 405 | trust-analyzer cargo palette 0.7.6 ok_utils/ST#t.: lc.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().lc.lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness.), |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | impl<T> STrust-analyzer cargo palette 0.7.6 ok_utils/ST#<T> |
| 411 | where |
| 412 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Onerust-analyzer cargo palette 0.7.6 num/One# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 413 | { |
| 414 | /// Returns a smooth approximation of the location of the cusp. |
| 415 | /// |
| 416 | /// This polynomial was created by an optimization process. |
| 417 | /// It has been designed so that |
| 418 | /// |
| 419 | /// `S_mid < S_max` and |
| 420 | /// |
| 421 | /// `T_mid < T_max` |
| 422 | #[rustfmt::skip] |
| 423 | fn midrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ST<T>`]mid().(a_: T, b_: T) -> STrust-analyzer cargo palette 0.7.6 ok_utils/ST#<T> { |
| 424 | let s = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.11516993) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().( |
| 425 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(7.44778970) |
| 426 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.15901240) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_ |
| 427 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.19557347)+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.75198401) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_ |
| 428 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.13704948) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(10.02301043) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_ |
| 429 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().4.24894561) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(5.38770819) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.69891013) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&a_ |
| 430 | ))) |
| 431 | ); |
| 432 | |
| 433 | let t = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.11239642)+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::onerust-analyzer cargo palette 0.7.6 num/One#one().()/rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().( |
| 434 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.61320320) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.68124379) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_ |
| 435 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.40370612) |
| 436 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.90148123) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_ |
| 437 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.27087943) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.61223990) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&b_ |
| 438 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.00299215) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.45399568) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.14661872) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a_ |
| 439 | ))) |
| 440 | ); |
| 441 | STrust-analyzer cargo palette 0.7.6 ok_utils/ST# { srust-analyzer cargo palette 0.7.6 ok_utils/ST#s., trust-analyzer cargo palette 0.7.6 ok_utils/ST#t. } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /// Maps an `oklab_lightness` to an *sRGB* reference-white based lightness `L_r`. |
| 446 | /// |
| 447 | /// The `Oklab` lightness is relative, i.e. `0` is black, `1` is pure white, but |
| 448 | /// `Oklab` is scale independent -- i.e. the luminosity of `luminance == 1.0` is undefined. |
| 449 | /// Lightness values may mean different things in different contexts (maximum display |
| 450 | /// luminosity, background brightness and other viewing conditions). |
| 451 | /// |
| 452 | /// *sRGB* however has a well defined dynamic range and a |
| 453 | /// [D65](https://en.wikipedia.org/wiki/Illuminant_D65) reference white luminance. |
| 454 | /// Mapping `1` to that luminance is just a matter of definition. But is say `0.8` `Oklab` |
| 455 | /// lightness equal to `0.5` or `0.9` `sRGB` luminance? |
| 456 | /// |
| 457 | /// The shape and weights of `L_r` are chosen to closely matches the lightness estimate of |
| 458 | /// the `CIELab` color space and be nearly equal at `0.5`. |
| 459 | /// |
| 460 | /// Inverse of [`toe_inv`] |
| 461 | /// |
| 462 | /// # See |
| 463 | /// https://bottosson.github.io/posts/colorpicker/#intermission---a-new-lightness-estimate-for-oklab |
| 464 | pub(craterust-analyzer cargo palette 0.7.6 crate/) fn toerust-analyzer cargo palette 0.7.6 ok_utils/toe().<T>(oklab_lightness: T) -> T |
| 465 | where |
| 466 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Powirust-analyzer cargo palette 0.7.6 num/Powi# + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Onerust-analyzer cargo palette 0.7.6 num/One# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 467 | { |
| 468 | let k_1 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.206); |
| 469 | let k_2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.03); |
| 470 | let k_3 = (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&k_1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&k_2); |
| 471 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5) |
| 472 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(k_3.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&oklab_lightness rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&k_1 |
| 473 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#sqrt().( |
| 474 | (k_3.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&oklab_lightness rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().k_1).powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) |
| 475 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().oklab_lightness, |
| 476 | )) |
| 477 | } |
| 478 | |
| 479 | /// Maps a *sRGB* reference-white based lightness to `Oklab`s scale-independent luminance. |
| 480 | /// |
| 481 | /// Inverse of [`toe`] |
| 482 | pub(craterust-analyzer cargo palette 0.7.6 crate/) fn toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().<T>(l_r: T) -> T |
| 483 | where |
| 484 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Powirust-analyzer cargo palette 0.7.6 num/Powi# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Onerust-analyzer cargo palette 0.7.6 num/One# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 485 | { |
| 486 | let k_1 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.206); |
| 487 | let k_2 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.03); |
| 488 | let k_3 = (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&k_1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&k_2); |
| 489 | (l_r.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().k_1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_r) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(k_3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(l_r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().k_2)) |
| 490 | } |
| 491 | |
| 492 | #[cfg(feature = "approx")] |
| 493 | #[cfg(test)] |
| 494 | mod testsrust-analyzer cargo palette 0.7.6 ok_utils/tests/ { |
| 495 | |
| 496 | use superrust-analyzer cargo palette 0.7.6 ok_utils/::*; |
| 497 | use craterust-analyzer cargo palette 0.7.6 crate/::convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#; |
| 498 | use craterust-analyzer cargo palette 0.7.6 crate/::rgbrust-analyzer cargo palette 0.7.6 rgb/::Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#; |
| 499 | use craterust-analyzer cargo palette 0.7.6 crate/::{encodingrust-analyzer cargo palette 0.7.6 encoding/, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#, Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#}; |
| 500 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 501 | |
| 502 | #[cfg_attr(miri, ignore)] |
| 503 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 504 | fn test_roundtrip_toe_is_originalrust-analyzer cargo palette 0.7.6 ok_utils/tests/test_roundtrip_toe_is_original().() { |
| 505 | let n = 500; |
| 506 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n { |
| 507 | let x = i as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().n as f64; |
| 508 | assert_ulps_eqrust-analyzer cargo approx 0.5.1 macros/assert_ulps_eq!!(toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().(toerust-analyzer cargo palette 0.7.6 ok_utils/toe().(x)), x); |
| 509 | } |
| 510 | |
| 511 | let x = 1000.0; |
| 512 | assert_ulps_eqrust-analyzer cargo approx 0.5.1 macros/assert_ulps_eq!!(toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().(toerust-analyzer cargo palette 0.7.6 ok_utils/toe().(x)), x); |
| 513 | } |
| 514 | |
| 515 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 516 | fn test_toerust-analyzer cargo palette 0.7.6 ok_utils/tests/test_toe().() { |
| 517 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(toerust-analyzer cargo palette 0.7.6 ok_utils/toe().(0.0), 0.0); |
| 518 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(toerust-analyzer cargo palette 0.7.6 ok_utils/toe().(1.0), 1.0); |
| 519 | let grey50srgb: Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb# = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#777777") |
| 520 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 521 | .into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().(); |
| 522 | let grey50oklab = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(grey50srgb); |
| 523 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("grey 50% oklab lightness: {}", grey50oklab.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l.); |
| 524 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(toerust-analyzer cargo palette 0.7.6 ok_utils/toe().(grey50oklab.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l.), 0.5, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 1e-3); |
| 525 | } |
| 526 | |
| 527 | #[cfg_attr(miri, ignore)] |
| 528 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 529 | fn print_min_max_srgb_chroma_of_all_huesrust-analyzer cargo palette 0.7.6 ok_utils/tests/print_min_max_srgb_chroma_of_all_hues().() { |
| 530 | struct HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#<T: Realrust-analyzer cargo palette 0.7.6 num/Real#> { |
| 531 | huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue.: OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>, |
| 532 | lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc.: LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#<T>, |
| 533 | } |
| 534 | |
| 535 | let mut min_chroma: HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#<f64> = HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc# { |
| 536 | huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue.: OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#::newrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]new().(f64::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]NAN.), |
| 537 | lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc.: LCrust-analyzer cargo palette 0.7.6 ok_utils/LC# { |
| 538 | lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness.: 0.0, |
| 539 | chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma.: f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY., |
| 540 | }, |
| 541 | }; |
| 542 | let mut max_chroma: HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#<f64> = HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc# { |
| 543 | huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue.: OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#::newrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]new().(f64::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]NAN.), |
| 544 | lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc.: LCrust-analyzer cargo palette 0.7.6 ok_utils/LC# { |
| 545 | lightnessrust-analyzer cargo palette 0.7.6 ok_utils/LC#lightness.: 0.0, |
| 546 | chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma.: 0.0, |
| 547 | }, |
| 548 | }; |
| 549 | let mut min_a = f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.; |
| 550 | let mut min_b = f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.; |
| 551 | let mut max_a = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.; |
| 552 | let mut max_b = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.; |
| 553 | |
| 554 | // use 300000 for actually computing values (takes < 10 seconds) |
| 555 | const SAMPLE_RESOLUTIONrust-analyzer cargo palette 0.7.6 ok_utils/tests/SAMPLE_RESOLUTION.: usize = 3; |
| 556 | |
| 557 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#SAMPLE_RESOLUTIONrust-analyzer cargo palette 0.7.6 ok_utils/tests/SAMPLE_RESOLUTION. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().360 { |
| 558 | let hue: OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<f64> = OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#::newrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]new().(i as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(SAMPLE_RESOLUTIONrust-analyzer cargo palette 0.7.6 ok_utils/tests/SAMPLE_RESOLUTION. as f64)); |
| 559 | let (lc, a, b) = hue.srgb_limitsrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`OklabHue<T>`]srgb_limits().(); |
| 560 | if lc.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().min_chroma.lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc..chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. { |
| 561 | min_chroma = HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc# { huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue., lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc. }; |
| 562 | } |
| 563 | if lc.chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().max_chroma.lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc..chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma. { |
| 564 | max_chroma = HueLcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc# { huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue., lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc. }; |
| 565 | } |
| 566 | max_a = f64::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]max().(max_a, a); |
| 567 | min_a = f64::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]min().(min_a, a); |
| 568 | max_b = f64::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]max().(max_b, b); |
| 569 | min_b = f64::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]min().(min_b, b); |
| 570 | } |
| 571 | |
| 572 | let (normalized_a, normalized_b) = max_chroma.huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue..into_cartesianrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]into_cartesian().(); |
| 573 | let (max_chroma_a, max_chroma_b) = ( |
| 574 | normalized_a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().max_chroma.lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc..chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma., |
| 575 | normalized_b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().max_chroma.lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc..chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma., |
| 576 | ); |
| 577 | |
| 578 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 579 | "Min chroma {} at hue {:?}°.", |
| 580 | min_chroma.lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc..chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma., min_chroma.huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue., |
| 581 | ); |
| 582 | |
| 583 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 584 | "Max chroma {} at hue {:?}° (Oklab a and b {}, {}).", |
| 585 | max_chroma.lcrust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#lc..chromarust-analyzer cargo palette 0.7.6 ok_utils/LC#chroma., max_chroma.huerust-analyzer cargo palette 0.7.6 ok_utils/tests/HueLc#hue., max_chroma_a, max_chroma_b |
| 586 | ); |
| 587 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} <= a <= {}", min_a, max_a); |
| 588 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{} <= b <= {}", min_b, max_b); |
| 589 | } |
| 590 | |
| 591 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 592 | fn max_saturation_f64_eq_f32rust-analyzer cargo palette 0.7.6 ok_utils/tests/max_saturation_f64_eq_f32().() { |
| 593 | let lin_srgb = LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 0.0, 1.0); |
| 594 | let oklab_64 = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::<f64>::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(lin_srgb); |
| 595 | let (normalized_a, normalized_b) = ( |
| 596 | oklab_64.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().oklab_64.get_chromarust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]get_chroma().(), |
| 597 | oklab_64.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().oklab_64.get_chromarust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]get_chroma().(), |
| 598 | ); |
| 599 | let saturation_64 = LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#::max_saturationrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]max_saturation().(normalized_a, normalized_b); |
| 600 | let saturation_32 = LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#::max_saturationrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]max_saturation().(normalized_a as f32, normalized_b as f32); |
| 601 | |
| 602 | // EPSILON should be 1e-6. See issue https://github.com/Ogeon/palette/issues/296 |
| 603 | const EPSILONrust-analyzer cargo palette 0.7.6 ok_utils/tests/EPSILON.: f32 = 3e-1; |
| 604 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!( |
| 605 | saturation_32, |
| 606 | saturation_64 as f32, |
| 607 | epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = EPSILONrust-analyzer cargo palette 0.7.6 ok_utils/tests/EPSILON., |
| 608 | max_relativerust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]max_relative(). = EPSILONrust-analyzer cargo palette 0.7.6 ok_utils/tests/EPSILON. |
| 609 | ); |
| 610 | } |
| 611 | } |