| 1 | //! Types for the HWB color space. |
| 2 | |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#, markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#}; |
| 4 | |
| 5 | #[cfg(feature = "random")] |
| 6 | use craterust-analyzer cargo palette 0.7.6 crate/::hsvrust-analyzer cargo palette 0.7.6 hsv/::UniformHsvrust-analyzer cargo palette 0.7.6 hsv/UniformHsv#; |
| 7 | |
| 8 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 9 | anglerust-analyzer cargo palette 0.7.6 angle/::FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#, |
| 10 | bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::{HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#, Selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#}, |
| 11 | convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, |
| 12 | encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, |
| 13 | huesrust-analyzer cargo palette 0.7.6 hues/::RgbHueIterrust-analyzer cargo palette 0.7.6 hues/RgbHueIter#, |
| 14 | numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, Onerust-analyzer cargo palette 0.7.6 num/One#, PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, Realrust-analyzer cargo palette 0.7.6 num/Real#}, |
| 15 | rgbrust-analyzer cargo palette 0.7.6 rgb/::{RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#}, |
| 16 | stimulusrust-analyzer cargo palette 0.7.6 stimulus/::{FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#, Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#}, |
| 17 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#, FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#, |
| 18 | }; |
| 19 | |
| 20 | /// Linear HWB with an alpha component. See the [`Hwba` implementation in |
| 21 | /// `Alpha`](crate::Alpha#Hwba). |
| 22 | pub type Hwbarust-analyzer cargo palette 0.7.6 hwb/Hwba#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> = Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T>, T>; |
| 23 | |
| 24 | /// HWB color space. |
| 25 | /// |
| 26 | /// HWB is a cylindrical version of [RGB](crate::rgb::Rgb) and it's very |
| 27 | /// closely related to [HSV](crate::Hsv). It describes colors with a |
| 28 | /// starting hue, then a degree of whiteness and blackness to mix into that |
| 29 | /// base hue. |
| 30 | /// |
| 31 | /// HWB component values are typically real numbers (such as floats), but may |
| 32 | /// also be converted to and from `u8` for storage and interoperability |
| 33 | /// purposes. The hue is then within the range `[0, 255]`. |
| 34 | /// |
| 35 | /// ``` |
| 36 | /// use approx::assert_relative_eq; |
| 37 | /// use palette::Hwb; |
| 38 | /// |
| 39 | /// let hwb_u8 = Hwb::new_srgb(128u8, 85, 51); |
| 40 | /// let hwb_f32 = hwb_u8.into_format::<f32>(); |
| 41 | /// |
| 42 | /// assert_relative_eq!(hwb_f32, Hwb::new(180.0, 1.0 / 3.0, 0.2)); |
| 43 | /// ``` |
| 44 | /// |
| 45 | /// It is very intuitive for humans to use and many color-pickers are based on |
| 46 | /// the HWB color system |
| 47 | #[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:, ArrayCastrust-analyzer cargo palette_derive 0.7.6 ArrayCast:, FromColorUnclampedrust-analyzer cargo palette_derive 0.7.6 FromColorUnclamped:, WithAlpharust-analyzer cargo palette_derive 0.7.6 WithAlpha:)] |
| 48 | #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 49 | #[palette( |
| 50 | palette_internal, |
| 51 | rgb_standard = "S", |
| 52 | component = "T", |
| 53 | skip_derives(Hsv, Hwb) |
| 54 | )] |
| 55 | #[repr(C)] |
| 56 | pub struct Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> { |
| 57 | /// The hue of the color, in degrees. Decides if it's red, blue, purple, |
| 58 | /// etc. Same as the hue for HSL and HSV. |
| 59 | #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_same_layout_as = "T")] |
| 60 | pub huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue.: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, |
| 61 | |
| 62 | /// The whiteness of the color. It specifies the amount white to mix into |
| 63 | /// the hue. It varies from 0 to 1, with 1 being always full white and 0 |
| 64 | /// always being the color shade (a mixture of a pure hue with black) |
| 65 | /// chosen with the other two controls. |
| 66 | pub whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness.: T, |
| 67 | |
| 68 | /// The blackness of the color. It specifies the amount black to mix into |
| 69 | /// the hue. It varies from 0 to 1, with 1 being always full black and |
| 70 | /// 0 always being the color tint (a mixture of a pure hue with white) |
| 71 | /// chosen with the other two |
| 72 | //controls. |
| 73 | pub blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.: T, |
| 74 | |
| 75 | /// The white point and RGB primaries this color is adapted to. The default |
| 76 | /// is the sRGB standard. |
| 77 | #[cfg_attr(feature = "serializing", serde(skip))] |
| 78 | #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_zero_sized)] |
| 79 | pub standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<S>, |
| 80 | } |
| 81 | |
| 82 | impl<T> Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T> { |
| 83 | /// Create an sRGB HWB color. This method can be used instead of `Hwb::new` |
| 84 | /// to help type inference. |
| 85 | pub fn new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, whiteness: T, blackness: T) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`] { |
| 86 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), whiteness, blackness) |
| 87 | } |
| 88 | |
| 89 | /// Create an sRGB HWB color. This is the same as `Hwb::new_srgb` without the |
| 90 | /// generic hue type. It's temporary until `const fn` supports traits. |
| 91 | pub const fn new_srgb_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, whiteness: T, blackness: T) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`] { |
| 92 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new_const().(hue, whiteness, blackness) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | impl<S, T> Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> { |
| 97 | /// Create an HWB color. |
| 98 | pub fn newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, whiteness: T, blackness: T) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`] { |
| 99 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), whiteness, blackness) |
| 100 | } |
| 101 | |
| 102 | /// Create an HWB color. This is the same as `Hwb::new` without the generic |
| 103 | /// hue type. It's temporary until `const fn` supports traits. |
| 104 | pub const fn new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, whiteness: T, blackness: T) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`] { |
| 105 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb# { |
| 106 | huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., |
| 107 | whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., |
| 108 | blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness., |
| 109 | standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | /// Convert into another component type. |
| 114 | pub fn into_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]into_format().<U>(self) -> Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, U> |
| 115 | where |
| 116 | U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>, |
| 117 | { |
| 118 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb# { |
| 119 | huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue.: self.huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue..into_formatrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]into_format().(), |
| 120 | whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness.), |
| 121 | blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.), |
| 122 | standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /// Convert from another component type. |
| 127 | pub fn from_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]from_format().<U>(color: Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, U>) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`] |
| 128 | where |
| 129 | T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<U>, |
| 130 | { |
| 131 | color.into_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]into_format().() |
| 132 | } |
| 133 | |
| 134 | /// Convert to a `(hue, whiteness, blackness)` tuple. |
| 135 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]into_components().(self) -> (RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, T, T) { |
| 136 | (self.huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., self.whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., self.blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.) |
| 137 | } |
| 138 | |
| 139 | /// Convert from a `(hue, whiteness, blackness)` tuple. |
| 140 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>((hue, whiteness, blackness): (H, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`] { |
| 141 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new().(hue, whiteness, blackness) |
| 142 | } |
| 143 | |
| 144 | #[inline] |
| 145 | fn reinterpret_asrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]reinterpret_as().<St>(self) -> Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<St, T> { |
| 146 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb# { |
| 147 | huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue.: self.huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., |
| 148 | whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness.: self.whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., |
| 149 | blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.: self.blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness., |
| 150 | standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | impl<S, T> Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> |
| 156 | where |
| 157 | T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 158 | { |
| 159 | /// Return the `whiteness` value minimum. |
| 160 | pub fn min_whitenessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]min_whiteness().() -> T { |
| 161 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 162 | } |
| 163 | |
| 164 | /// Return the `whiteness` value maximum. |
| 165 | pub fn max_whitenessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]max_whiteness().() -> T { |
| 166 | T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().() |
| 167 | } |
| 168 | |
| 169 | /// Return the `blackness` value minimum. |
| 170 | pub fn min_blacknessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]min_blackness().() -> T { |
| 171 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 172 | } |
| 173 | |
| 174 | /// Return the `blackness` value maximum. |
| 175 | pub fn max_blacknessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]max_blackness().() -> T { |
| 176 | T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().() |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | ///<span id="Hwba"></span>[`Hwba`](crate::Hwba) implementations. |
| 181 | impl<T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T>, A> { |
| 182 | /// Create an sRGB HWB color with transparency. This method can be used |
| 183 | /// instead of `Hwba::new` to help type inference. |
| 184 | pub fn new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<Srgb, T>, A>`]new_srgb().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, whiteness: T, blackness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<Srgb, T>, A>`] { |
| 185 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<Srgb, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), whiteness, blackness, alpha) |
| 186 | } |
| 187 | |
| 188 | /// Create an sRGB HWB color with transparency. This is the same as |
| 189 | /// `Hwba::new_srgb` without the generic hue type. It's temporary until `const |
| 190 | /// fn` supports traits. |
| 191 | pub const fn new_srgb_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<Srgb, T>, A>`]new_srgb_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, whiteness: T, blackness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<Srgb, T>, A>`] { |
| 192 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<Srgb, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new_const().(hue, whiteness, blackness, alpha) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | ///<span id="Hwba"></span>[`Hwba`](crate::Hwba) implementations. |
| 197 | impl<S, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T>, A> { |
| 198 | /// Create an HWB color with transparency. |
| 199 | pub fn newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, whiteness: T, blackness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`] { |
| 200 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), whiteness, blackness, alpha) |
| 201 | } |
| 202 | |
| 203 | /// Create an HWB color with transparency. This is the same as `Hwba::new` without the |
| 204 | /// generic hue type. It's temporary until `const fn` supports traits. |
| 205 | pub const fn new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, whiteness: T, blackness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`] { |
| 206 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# { |
| 207 | colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_construst-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new_const().(hue, whiteness, blackness), |
| 208 | alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha., |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /// Convert into another component type. |
| 213 | pub fn into_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]into_format().<U, B>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, U>, B> |
| 214 | where |
| 215 | U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>, |
| 216 | B: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<A>, |
| 217 | { |
| 218 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# { |
| 219 | colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..into_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]into_format().(), |
| 220 | alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.: B::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.), |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | /// Convert from another component type. |
| 225 | pub fn from_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]from_format().<U, B>(color: Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, U>, B>) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`] |
| 226 | where |
| 227 | T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<U>, |
| 228 | A: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<B>, |
| 229 | { |
| 230 | color.into_formatrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]into_format().() |
| 231 | } |
| 232 | |
| 233 | /// Convert to a `(hue, whiteness, blackness, alpha)` tuple. |
| 234 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]into_components().(self) -> (RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, T, T, A) { |
| 235 | ( |
| 236 | self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., |
| 237 | self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., |
| 238 | self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness., |
| 239 | self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha., |
| 240 | ) |
| 241 | } |
| 242 | |
| 243 | /// Convert from a `(hue, whiteness, blackness, alpha)` tuple. |
| 244 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>( |
| 245 | (hue, whiteness, blackness, alpha): (H, T, T, A), |
| 246 | ) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`] { |
| 247 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new().(hue, whiteness, blackness, alpha) |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | impl_reference_component_methods_huerust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, [whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 252 | impl_struct_of_arrays_methods_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, [whiteness, blackness], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 253 | |
| 254 | impl<S1, S2, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S1, T>> for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S2, T> |
| 255 | where |
| 256 | S1: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static, |
| 257 | S2: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static, |
| 258 | S1::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#<WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint# = <S2::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#>, |
| 259 | Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S1, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S1, T>>, |
| 260 | Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S2, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S1, T>>, |
| 261 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S2, T>`][`FromColorUnclamped<Hwb<S1, T>>`]: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S2, T>>, |
| 262 | { |
| 263 | #[inline] |
| 264 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S2, T>`][`FromColorUnclamped<Hwb<S1, T>>`]from_color_unclamped().(hwb: Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S1, T>) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S2, T>`][`FromColorUnclamped<Hwb<S1, T>>`] { |
| 265 | if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S1>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S2>() { |
| 266 | hwb.reinterpret_asrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]reinterpret_as().() |
| 267 | } else { |
| 268 | let hsv = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::<S1, T>::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(hwb); |
| 269 | let converted_hsv = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::<S2, T>::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(hsv); |
| 270 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S2, T>`][`FromColorUnclamped<Hwb<S1, T>>`]::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(converted_hsv) |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>> for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> |
| 276 | where |
| 277 | T: Onerust-analyzer cargo palette 0.7.6 num/One# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, |
| 278 | { |
| 279 | #[inline] |
| 280 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][`FromColorUnclamped<Hsv<S, T>>`]from_color_unclamped().(color: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][`FromColorUnclamped<Hsv<S, T>>`] { |
| 281 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb# { |
| 282 | huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue.: color.huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., |
| 283 | whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness.: (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().color.saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.) rust-analyzer cargo core https://github.com/rust-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().&color.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value., |
| 284 | blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.: (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().color.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.), |
| 285 | standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | impl_tuple_conversion_huerust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S> as (H, T, T), RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#); |
| 291 | impl_is_within_bounds_hwbrust-analyzer cargo palette 0.7.6 macros/clamp/impl_is_within_bounds_hwb!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S> where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#); |
| 292 | impl_clamp_hwbrust-analyzer cargo palette 0.7.6 macros/clamp/impl_clamp_hwb!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S> phantom: standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard. where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#); |
| 293 | |
| 294 | impl_mix_huerust-analyzer cargo palette 0.7.6 macros/mix/impl_mix_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S> {whiteness, blackness} phantom: standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 295 | impl_lighten_hwbrust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_lighten_hwb!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S> phantom: standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard. where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#); |
| 296 | impl_hue_opsrust-analyzer cargo palette 0.7.6 macros/hue/impl_hue_ops!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#); |
| 297 | |
| 298 | impl<S, T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> |
| 299 | where |
| 300 | T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, |
| 301 | { |
| 302 | type Maskrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#; |
| 303 | } |
| 304 | |
| 305 | impl<S, T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> |
| 306 | where |
| 307 | T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 308 | RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 309 | { |
| 310 | fn defaultrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Default]default().() -> Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> { |
| 311 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new().( |
| 312 | RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), |
| 313 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Default]::min_whitenessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]min_whiteness().(), |
| 314 | Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Default]::max_blacknessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]max_blackness().(), |
| 315 | ) |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | impl_color_addrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_add!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, [huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 320 | impl_color_subrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_sub!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, [huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 321 | |
| 322 | impl_array_castsrust-analyzer cargo palette 0.7.6 macros/casting/impl_array_casts!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T>, [T; 3]); |
| 323 | impl_simd_array_conversion_huerust-analyzer cargo palette 0.7.6 macros/simd/impl_simd_array_conversion_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, [whiteness, blackness], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 324 | impl_struct_of_array_traits_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_array_traits_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, RgbHueIterrust-analyzer cargo palette 0.7.6 hues/RgbHueIter#, [whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 325 | |
| 326 | impl_copy_clonerust-analyzer cargo palette 0.7.6 macros/copy_clone/impl_copy_clone!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, [huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.], standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard.); |
| 327 | impl_eq_huerust-analyzer cargo palette 0.7.6 macros/equality/impl_eq_hue!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, [huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.]); |
| 328 | |
| 329 | #[allow(deprecated)] |
| 330 | impl<S, T> craterust-analyzer cargo palette 0.7.6 crate/::RelativeContrastrust-analyzer cargo palette 0.7.6 relative_contrast/RelativeContrast# for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> |
| 331 | where |
| 332 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, |
| 333 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>, |
| 334 | S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#, |
| 335 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>: FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#<Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][RelativeContrast]>, |
| 336 | { |
| 337 | type Scalarrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][RelativeContrast]Scalar# = T; |
| 338 | |
| 339 | #[inline] |
| 340 | fn get_contrast_ratiorust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][RelativeContrast]get_contrast_ratio().(self, other: Selfrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][RelativeContrast]) -> T { |
| 341 | let xyz1 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(self); |
| 342 | let xyz2 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(other); |
| 343 | |
| 344 | craterust-analyzer cargo palette 0.7.6 crate/::contrast_ratiorust-analyzer cargo palette 0.7.6 relative_contrast/contrast_ratio().(xyz1.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., xyz2.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.) |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | impl_rand_traits_hwb_conerust-analyzer cargo palette 0.7.6 macros/random/impl_rand_traits_hwb_cone!!( |
| 349 | UniformHwbrust-analyzer cargo palette 0.7.6 hwb/UniformHwb#, |
| 350 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S>, |
| 351 | UniformHsvrust-analyzer cargo palette 0.7.6 hsv/UniformHsv#, |
| 352 | Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# { |
| 353 | height: valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value., |
| 354 | radius: saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation. |
| 355 | } |
| 356 | phantom: standardrust-analyzer cargo palette 0.7.6 hwb/UniformHwb#standard.: PhantomData<S> |
| 357 | ); |
| 358 | |
| 359 | #[cfg(feature = "bytemuck")] |
| 360 | unsafe impl<S, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {} |
| 361 | |
| 362 | #[cfg(feature = "bytemuck")] |
| 363 | unsafe impl<S: 'static, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {} |
| 364 | |
| 365 | #[cfg(test)] |
| 366 | mod testrust-analyzer cargo palette 0.7.6 hwb/test/ { |
| 367 | use superrust-analyzer cargo palette 0.7.6 hwb/::Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#; |
| 368 | |
| 369 | test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#); |
| 370 | |
| 371 | #[cfg(feature = "approx")] |
| 372 | mod conversionrust-analyzer cargo palette 0.7.6 hwb/test/conversion/ { |
| 373 | use craterust-analyzer cargo palette 0.7.6 crate/::{FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#, Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#}; |
| 374 | |
| 375 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 376 | fn redrust-analyzer cargo palette 0.7.6 hwb/test/conversion/red().() { |
| 377 | let a = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1.0, 0.0, 0.0)); |
| 378 | let b = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(0.0, 0.0, 0.0); |
| 379 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 380 | } |
| 381 | |
| 382 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 383 | fn orangerust-analyzer cargo palette 0.7.6 hwb/test/conversion/orange().() { |
| 384 | let a = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1.0, 0.5, 0.0)); |
| 385 | let b = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(30.0, 0.0, 0.0); |
| 386 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 387 | } |
| 388 | |
| 389 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 390 | fn greenrust-analyzer cargo palette 0.7.6 hwb/test/conversion/green().() { |
| 391 | let a = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 1.0, 0.0)); |
| 392 | let b = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(120.0, 0.0, 0.0); |
| 393 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 394 | } |
| 395 | |
| 396 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 397 | fn bluerust-analyzer cargo palette 0.7.6 hwb/test/conversion/blue().() { |
| 398 | let a = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 0.0, 1.0)); |
| 399 | let b = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.0, 0.0); |
| 400 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 401 | } |
| 402 | |
| 403 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 404 | fn purplerust-analyzer cargo palette 0.7.6 hwb/test/conversion/purple().() { |
| 405 | let a = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.5, 0.0, 1.0)); |
| 406 | let b = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(270.0, 0.0, 0.0); |
| 407 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | #[cfg(feature = "approx")] |
| 412 | mod clamprust-analyzer cargo palette 0.7.6 hwb/test/clamp/ { |
| 413 | use craterust-analyzer cargo palette 0.7.6 crate/::{Clamprust-analyzer cargo palette 0.7.6 Clamp#, Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#}; |
| 414 | |
| 415 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 416 | fn clamp_invalidrust-analyzer cargo palette 0.7.6 hwb/test/clamp/clamp_invalid().() { |
| 417 | let expected = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.0, 0.0); |
| 418 | let clamped = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().3.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().4.0).clamprust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Clamp]clamp().(); |
| 419 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(expected, clamped); |
| 420 | } |
| 421 | |
| 422 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 423 | fn clamp_nonerust-analyzer cargo palette 0.7.6 hwb/test/clamp/clamp_none().() { |
| 424 | let expected = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.3, 0.7); |
| 425 | let clamped = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.3, 0.7).clamprust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Clamp]clamp().(); |
| 426 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(expected, clamped); |
| 427 | } |
| 428 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 429 | fn clamp_over_onerust-analyzer cargo palette 0.7.6 hwb/test/clamp/clamp_over_one().() { |
| 430 | let expected = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.2, 0.8); |
| 431 | let clamped = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 5.0, 20.0).clamprust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Clamp]clamp().(); |
| 432 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(expected, clamped); |
| 433 | } |
| 434 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 435 | fn clamp_under_onerust-analyzer cargo palette 0.7.6 hwb/test/clamp/clamp_under_one().() { |
| 436 | let expected = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.3, 0.1); |
| 437 | let clamped = Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(240.0, 0.3, 0.1).clamprust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`][Clamp]clamp().(); |
| 438 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(expected, clamped); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | raw_pixel_conversion_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_tests!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>: hue, whiteness, blackness); |
| 443 | raw_pixel_conversion_fail_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_fail_tests!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>: hue, whiteness, blackness); |
| 444 | |
| 445 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 446 | fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 hwb/test/check_min_max_components().() { |
| 447 | use craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#; |
| 448 | |
| 449 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::min_whitenessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]min_whiteness().(), 0.0,); |
| 450 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::min_blacknessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]min_blackness().(), 0.0,); |
| 451 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::max_whitenessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]max_whiteness().(), 1.0,); |
| 452 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::max_blacknessrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]max_blackness().(), 1.0,); |
| 453 | } |
| 454 | |
| 455 | struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!( |
| 456 | Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>[huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue., whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.] phantom: standardrust-analyzer cargo palette 0.7.6 hwb/Hwb#standard., |
| 457 | superrust-analyzer cargo palette 0.7.6 hwb/::Hwbarust-analyzer cargo palette 0.7.6 hwb/Hwba#::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4), |
| 458 | superrust-analyzer cargo palette 0.7.6 hwb/::Hwbarust-analyzer cargo palette 0.7.6 hwb/Hwba#::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new().(0.2, 0.3, 0.4, 0.5), |
| 459 | superrust-analyzer cargo palette 0.7.6 hwb/::Hwbarust-analyzer cargo palette 0.7.6 hwb/Hwba#::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Alpha<Hwb<S, T>, A>`]new().(0.3, 0.4, 0.5, 0.6) |
| 460 | ); |
| 461 | |
| 462 | #[cfg(feature = "serializing")] |
| 463 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 464 | fn serializerust-analyzer cargo palette 0.7.6 hwb/test/serialize().() { |
| 465 | let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::new_srgbrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<Srgb, T>`]new_srgb().(0.3, 0.8, 0.1)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 466 | |
| 467 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#"{"hue":0.3,"whiteness":0.8,"blackness":0.1}"#); |
| 468 | } |
| 469 | |
| 470 | #[cfg(feature = "serializing")] |
| 471 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 472 | fn deserializerust-analyzer cargo palette 0.7.6 hwb/test/deserialize().() { |
| 473 | let deserialized: Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb# = |
| 474 | ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::from_strrust-analyzer cargo serde_json 1.0.116 de/from_str().(r#"{"hue":0.3,"whiteness":0.8,"blackness":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 475 | |
| 476 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#::newrust-analyzer cargo palette 0.7.6 hwb/impl#[`Hwb<S, T>`]new().(0.3, 0.8, 0.1)); |
| 477 | } |
| 478 | |
| 479 | test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! { |
| 480 | Hwb<crate::encoding::Srgb, f32> as crate::rgb::Rgb { |
| 481 | red: (0.0, 1.0), |
| 482 | green: (0.0, 1.0), |
| 483 | blue: (0.0, 1.0) |
| 484 | }, |
| 485 | min: Hwb::new(0.0f32, 0.0, 0.0), |
| 486 | max: Hwb::new(360.0, 1.0, 1.0) |
| 487 | } |
| 488 | } |