| 1 |
//! Types for the HSL 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#, opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Notrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/Not#}; |
| 4 |
|
| 5 |
use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 6 |
anglerust-analyzer cargo palette 0.7.6 angle/::{FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#, RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#}, |
| 7 |
bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::{BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps#, BoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#, 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#}, |
| 8 |
convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, |
| 9 |
encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, |
| 10 |
huesrust-analyzer cargo palette 0.7.6 hues/::RgbHueIterrust-analyzer cargo palette 0.7.6 hues/RgbHueIter#, |
| 11 |
numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#, MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#, 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#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#}, |
| 12 |
rgbrust-analyzer cargo palette 0.7.6 rgb/::{Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#}, |
| 13 |
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#}, |
| 14 |
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#, |
| 15 |
}; |
| 16 |
|
| 17 |
/// Linear HSL with an alpha component. See the [`Hsla` implementation in |
| 18 |
/// `Alpha`](crate::Alpha#Hsla). |
| 19 |
pub type Hslarust-analyzer cargo palette 0.7.6 hsl/Hsla#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> = Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>, T>; |
| 20 |
|
| 21 |
/// HSL color space. |
| 22 |
/// |
| 23 |
/// The HSL color space can be seen as a cylindrical version of |
| 24 |
/// [RGB](crate::rgb::Rgb), where the `hue` is the angle around the color |
| 25 |
/// cylinder, the `saturation` is the distance from the center, and the |
| 26 |
/// `lightness` is the height from the bottom. Its composition makes it |
| 27 |
/// especially good for operations like changing green to red, making a color |
| 28 |
/// more gray, or making it darker. |
| 29 |
/// |
| 30 |
/// HSL component values are typically real numbers (such as floats), but may |
| 31 |
/// also be converted to and from `u8` for storage and interoperability |
| 32 |
/// purposes. The hue is then within the range `[0, 255]`. |
| 33 |
/// |
| 34 |
/// ``` |
| 35 |
/// use approx::assert_relative_eq; |
| 36 |
/// use palette::Hsl; |
| 37 |
/// |
| 38 |
/// let hsl_u8 = Hsl::new_srgb(128u8, 85, 51); |
| 39 |
/// let hsl_f32 = hsl_u8.into_format::<f32>(); |
| 40 |
/// |
| 41 |
/// assert_relative_eq!(hsl_f32, Hsl::new(180.0, 1.0 / 3.0, 0.2)); |
| 42 |
/// ``` |
| 43 |
/// |
| 44 |
/// See [HSV](crate::Hsv) for a very similar color space, with brightness |
| 45 |
/// instead of lightness. |
| 46 |
#[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:)] |
| 47 |
#[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 48 |
#[palette( |
| 49 |
palette_internal, |
| 50 |
rgb_standard = "S", |
| 51 |
component = "T", |
| 52 |
skip_derives(Rgb, Hsv, Hsl) |
| 53 |
)] |
| 54 |
#[repr(C)] |
| 55 |
pub struct Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> { |
| 56 |
/// The hue of the color, in degrees. Decides if it's red, blue, purple, |
| 57 |
/// etc. |
| 58 |
#[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_same_layout_as = "T")] |
| 59 |
pub huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue.: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, |
| 60 |
|
| 61 |
/// The colorfulness of the color. 0.0 gives gray scale colors and 1.0 will |
| 62 |
/// give absolutely clear colors. |
| 63 |
pub saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.: T, |
| 64 |
|
| 65 |
/// Decides how light the color will look. 0.0 will be black, 0.5 will give |
| 66 |
/// a clear color, and 1.0 will give white. |
| 67 |
pub lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.: T, |
| 68 |
|
| 69 |
/// The white point and RGB primaries this color is adapted to. The default |
| 70 |
/// is the sRGB standard. |
| 71 |
#[cfg_attr(feature = "serializing", serde(skip))] |
| 72 |
#[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_zero_sized)] |
| 73 |
pub standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<S>, |
| 74 |
} |
| 75 |
|
| 76 |
impl<T> Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T> { |
| 77 |
/// Create an sRGB HSL color. This method can be used instead of `Hsl::new` |
| 78 |
/// to help type inference. |
| 79 |
pub fn new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<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, saturation: T, lightness: T) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`] { |
| 80 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, lightness) |
| 81 |
} |
| 82 |
|
| 83 |
/// Create an sRGB HSL color. This is the same as `Hsl::new_srgb` without |
| 84 |
/// the generic hue type. It's temporary until `const fn` supports traits. |
| 85 |
pub const fn new_srgb_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, lightness: T) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`] { |
| 86 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new_const().(hue, saturation, lightness) |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
impl<S, T> Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> { |
| 91 |
/// Create an HSL color. |
| 92 |
pub fn newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<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, saturation: T, lightness: T) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`] { |
| 93 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, lightness) |
| 94 |
} |
| 95 |
|
| 96 |
/// Create an HSL color. This is the same as `Hsl::new` without the generic |
| 97 |
/// hue type. It's temporary until `const fn` supports traits. |
| 98 |
pub const fn new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, lightness: T) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`] { |
| 99 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# { |
| 100 |
huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., |
| 101 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., |
| 102 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness., |
| 103 |
standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
/// Convert into another component type. |
| 108 |
pub fn into_formatrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]into_format().<U>(self) -> Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, U> |
| 109 |
where |
| 110 |
U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>, |
| 111 |
{ |
| 112 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# { |
| 113 |
huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue.: self.huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue..into_formatrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]into_format().(), |
| 114 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.), |
| 115 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.), |
| 116 |
standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
/// Convert from another component type. |
| 121 |
pub fn from_formatrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]from_format().<U>(color: Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, U>) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`] |
| 122 |
where |
| 123 |
T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<U>, |
| 124 |
{ |
| 125 |
color.into_formatrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]into_format().() |
| 126 |
} |
| 127 |
|
| 128 |
/// Convert to a `(hue, saturation, lightness)` tuple. |
| 129 |
pub fn into_componentsrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]into_components().(self) -> (RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, T, T) { |
| 130 |
(self.huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., self.saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., self.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.) |
| 131 |
} |
| 132 |
|
| 133 |
/// Convert from a `(hue, saturation, lightness)` tuple. |
| 134 |
pub fn from_componentsrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<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, saturation, lightness): (H, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`] { |
| 135 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new().(hue, saturation, lightness) |
| 136 |
} |
| 137 |
|
| 138 |
#[inline] |
| 139 |
fn reinterpret_asrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]reinterpret_as().<St>(self) -> Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<St, T> { |
| 140 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# { |
| 141 |
huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue.: self.huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., |
| 142 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.: self.saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., |
| 143 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.: self.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness., |
| 144 |
standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 145 |
} |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
impl<S, T> Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> |
| 150 |
where |
| 151 |
T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 152 |
{ |
| 153 |
/// Return the `saturation` value minimum. |
| 154 |
pub fn min_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_saturation().() -> T { |
| 155 |
T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 156 |
} |
| 157 |
|
| 158 |
/// Return the `saturation` value maximum. |
| 159 |
pub fn max_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_saturation().() -> T { |
| 160 |
T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().() |
| 161 |
} |
| 162 |
|
| 163 |
/// Return the `lightness` value minimum. |
| 164 |
pub fn min_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_lightness().() -> T { |
| 165 |
T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 166 |
} |
| 167 |
|
| 168 |
/// Return the `lightness` value maximum. |
| 169 |
pub fn max_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_lightness().() -> T { |
| 170 |
T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().() |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
///<span id="Hsla"></span>[`Hsla`](crate::Hsla) implementations. |
| 175 |
impl<T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T>, A> { |
| 176 |
/// Create an sRGB HSL color with transparency. This method can be used |
| 177 |
/// instead of `Hsla::new` to help type inference. |
| 178 |
pub fn new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<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, saturation: T, lightness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<Srgb, T>, A>`] { |
| 179 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<Srgb, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, lightness, alpha) |
| 180 |
} |
| 181 |
|
| 182 |
/// Create an sRGB HSL color with transparency. This is the same as |
| 183 |
/// `Hsla::new_srgb` without the generic hue type. It's temporary until |
| 184 |
/// `const fn` supports traits. |
| 185 |
pub const fn new_srgb_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<Srgb, T>, A>`]new_srgb_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, lightness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<Srgb, T>, A>`] { |
| 186 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<Srgb, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new_const().(hue, saturation, lightness, alpha) |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
///<span id="Hsla"></span>[`Hsla`](crate::Hsla) implementations. |
| 191 |
impl<S, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>, A> { |
| 192 |
/// Create an HSL color with transparency. |
| 193 |
pub fn newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<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, saturation: T, lightness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`] { |
| 194 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, lightness, alpha) |
| 195 |
} |
| 196 |
|
| 197 |
/// Create an HSL color with transparency. This is the same as `Hsla::new` |
| 198 |
/// without the generic hue type. It's temporary until `const fn` supports |
| 199 |
/// traits. |
| 200 |
pub const fn new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, lightness: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`] { |
| 201 |
Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# { |
| 202 |
colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_construst-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new_const().(hue, saturation, lightness), |
| 203 |
alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha., |
| 204 |
} |
| 205 |
} |
| 206 |
/// Convert into another component type. |
| 207 |
pub fn into_formatrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]into_format().<U, B>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, U>, B> |
| 208 |
where |
| 209 |
U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>, |
| 210 |
B: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<A>, |
| 211 |
{ |
| 212 |
Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# { |
| 213 |
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 hsl/impl#[`Hsl<S, T>`]into_format().(), |
| 214 |
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.), |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
/// Convert from another component type. |
| 219 |
pub fn from_formatrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]from_format().<U, B>(color: Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, U>, B>) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`] |
| 220 |
where |
| 221 |
T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<U>, |
| 222 |
A: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<B>, |
| 223 |
{ |
| 224 |
color.into_formatrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]into_format().() |
| 225 |
} |
| 226 |
|
| 227 |
/// Convert to a `(hue, saturation, lightness, alpha)` tuple. |
| 228 |
pub fn into_componentsrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]into_components().(self) -> (RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, T, T, A) { |
| 229 |
( |
| 230 |
self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., |
| 231 |
self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., |
| 232 |
self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness., |
| 233 |
self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha., |
| 234 |
) |
| 235 |
} |
| 236 |
|
| 237 |
/// Convert from a `(hue, saturation, lightness, alpha)` tuple. |
| 238 |
pub fn from_componentsrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<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>>>( |
| 239 |
(hue, saturation, lightness, alpha): (H, T, T, A), |
| 240 |
) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`] { |
| 241 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new().(hue, saturation, lightness, alpha) |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
impl_reference_component_methods_huerust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, [saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 246 |
impl_struct_of_arrays_methods_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, [saturation, lightness], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 247 |
|
| 248 |
impl<S1, S2, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S1, T>> for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S2, T> |
| 249 |
where |
| 250 |
S1: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static, |
| 251 |
S2: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static, |
| 252 |
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#>, |
| 253 |
Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S1, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S1, T>>, |
| 254 |
Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S1, T>>, |
| 255 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S2, T>`][`FromColorUnclamped<Hsl<S1, T>>`]: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>>, |
| 256 |
{ |
| 257 |
#[inline] |
| 258 |
fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S2, T>`][`FromColorUnclamped<Hsl<S1, T>>`]from_color_unclamped().(hsl: Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S1, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S2, T>`][`FromColorUnclamped<Hsl<S1, T>>`] { |
| 259 |
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>() { |
| 260 |
hsl.reinterpret_asrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]reinterpret_as().() |
| 261 |
} else { |
| 262 |
let rgb = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<S1, T>::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(hsl); |
| 263 |
let converted_rgb = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<S2, T>::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(rgb); |
| 264 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S2, T>`][`FromColorUnclamped<Hsl<S1, T>>`]::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(converted_rgb) |
| 265 |
} |
| 266 |
} |
| 267 |
} |
| 268 |
|
| 269 |
impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>> for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> |
| 270 |
where |
| 271 |
T: RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Onerust-analyzer cargo palette 0.7.6 num/One# + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 272 |
T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: BoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/BoolMask# + BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps# + LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + 'static, |
| 273 |
{ |
| 274 |
fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(rgb: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][`FromColorUnclamped<Rgb<S, T>>`] { |
| 275 |
// Avoid negative numbers |
| 276 |
let red = rgb.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()); |
| 277 |
let green = rgb.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()); |
| 278 |
let blue = rgb.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()); |
| 279 |
|
| 280 |
// The SIMD optimized version showed significant slowdown for regular floats. |
| 281 |
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().::<T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#>() 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().::<bool>() { |
| 282 |
let (max, min, sep, coeff) = { |
| 283 |
let (max, min, sep, coeff) = if red.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&green).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() { |
| 284 |
(red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), green.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().&blue, T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()) |
| 285 |
} else { |
| 286 |
( |
| 287 |
green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 288 |
red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 289 |
blue.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().&red, |
| 290 |
T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0), |
| 291 |
) |
| 292 |
}; |
| 293 |
if blue.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&max).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() { |
| 294 |
(blue, min, red 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().green, T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0)) |
| 295 |
} else { |
| 296 |
let min_val = if blue.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&min).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() { blue } else { min }; |
| 297 |
(max, min_val, sep, coeff) |
| 298 |
} |
| 299 |
}; |
| 300 |
|
| 301 |
let mut h = T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(); |
| 302 |
let mut s = T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(); |
| 303 |
|
| 304 |
let sum = max.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().&min; |
| 305 |
let l = sum.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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0); |
| 306 |
if max.neqrust-analyzer cargo palette 0.7.6 num/PartialCmp#neq().(&min).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() { |
| 307 |
let d = max 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().min; |
| 308 |
s = if sum.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().()).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() { |
| 309 |
d.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().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0) 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().sum) |
| 310 |
} else { |
| 311 |
d.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().sum |
| 312 |
}; |
| 313 |
h = ((sep 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().d) 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().coeff) rust-analyzer cargo core https://github.com/rust-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().(60.0); |
| 314 |
}; |
| 315 |
|
| 316 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# { |
| 317 |
huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue.: h.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 318 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.: s, |
| 319 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.: l, |
| 320 |
standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 321 |
} |
| 322 |
} else { |
| 323 |
// Based on OPTIMIZED RGB TO HSV COLOR CONVERSION USING SSE TECHNOLOGY |
| 324 |
// by KOBALICEK, Petr & BLIZNAK, Michal |
| 325 |
// |
| 326 |
// This implementation assumes less about the underlying mask and number |
| 327 |
// representation. The hue is also multiplied by 6 to avoid rounding |
| 328 |
// errors when using degrees. |
| 329 |
|
| 330 |
let six = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0); |
| 331 |
|
| 332 |
let max = red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()).maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(blue.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 333 |
let min = red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().minrust-analyzer cargo palette 0.7.6 num/MinMax#min().(green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()).minrust-analyzer cargo palette 0.7.6 num/MinMax#min().(blue.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 334 |
|
| 335 |
let sum = max.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().&min; |
| 336 |
let lightness = 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().∑ |
| 337 |
|
| 338 |
let chroma = max.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().&min; |
| 339 |
let saturation = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 340 |
if min.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&max) => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 341 |
else => 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(). |
| 342 |
sum.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().()).selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0) -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). &sum, sum.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()), |
| 343 |
}; |
| 344 |
|
| 345 |
// Each of these represents an RGB component. The maximum will be false |
| 346 |
// while the two other will be true. They are later used for determining |
| 347 |
// which branch in the hue equation we end up in. |
| 348 |
let x = max.neqrust-analyzer cargo palette 0.7.6 num/PartialCmp#neq().(&red); |
| 349 |
let y = max.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&red) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().max.neqrust-analyzer cargo palette 0.7.6 num/PartialCmp#neq().(&green); |
| 350 |
let z = max.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&red) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().max.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&green); |
| 351 |
|
| 352 |
// The hue base is the `1`, `2/6`, `4/6` or 0 part of the hue equation, |
| 353 |
// except it's multiplied by 6 here. |
| 354 |
let hue_base = x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().( |
| 355 |
z.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(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.0), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0)), |
| 356 |
T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 357 |
) 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().&six; |
| 358 |
|
| 359 |
// Each of these is a part of `G - B`, `B - R`, `R - G` or 0 from the |
| 360 |
// hue equation. They become positive, negative or 0, depending on which |
| 361 |
// branch we should be in. This makes the sum of all three combine as |
| 362 |
// expected. |
| 363 |
let red_m = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 364 |
if x => y.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(red.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/Neg#neg().red), |
| 365 |
else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 366 |
}; |
| 367 |
let green_m = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 368 |
if y.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() => z.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(green.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/Neg#neg().green), |
| 369 |
else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 370 |
}; |
| 371 |
let blue_m = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 372 |
if z => y.selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().blue.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), blue), |
| 373 |
else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 374 |
}; |
| 375 |
|
| 376 |
// This is the hue equation parts combined. The hue base is the constant |
| 377 |
// and the RGB components are masked so up to two of them are non-zero. |
| 378 |
// Once again, this is multiplied by 6, so the chroma isn't multiplied |
| 379 |
// before dividing. |
| 380 |
// |
| 381 |
// We also avoid dividing by 0 for non-SIMD values. |
| 382 |
let hue = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 383 |
if chroma.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()) => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 384 |
else => hue_base +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). (red_m +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). green_m +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). blue_m) /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). &chroma, |
| 385 |
}; |
| 386 |
|
| 387 |
// hue will always be within [0, 12) (it's multiplied by 6, compared to |
| 388 |
// the paper), so we can subtract by 6 instead of using % to get it |
| 389 |
// within [0, 6). |
| 390 |
let hue_sub = hue.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&six).selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(six, T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()); |
| 391 |
let hue = hue 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().hue_sub; |
| 392 |
|
| 393 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# { |
| 394 |
huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue.: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#::from_degreesrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]from_degrees().(hue rust-analyzer cargo core https://github.com/rust-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().(60.0)), |
| 395 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., |
| 396 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness., |
| 397 |
standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 398 |
} |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
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 Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> |
| 404 |
where |
| 405 |
T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Onerust-analyzer cargo palette 0.7.6 num/One# + IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 406 |
T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + Notrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/Not#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/Not#Output# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#>, |
| 407 |
{ |
| 408 |
fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][`FromColorUnclamped<Hsv<S, T>>`]from_color_unclamped().(hsv: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][`FromColorUnclamped<Hsv<S, T>>`] { |
| 409 |
let Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# { |
| 410 |
huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., |
| 411 |
saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., |
| 412 |
valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value., |
| 413 |
.. |
| 414 |
} = hsv; |
| 415 |
|
| 416 |
let x = (T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0) 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().&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().&value; |
| 417 |
let saturation = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 418 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/Not#not().value.is_valid_divisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#is_valid_divisor().() => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 419 |
if x.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().()) => { |
| 420 |
lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!!{ |
| 421 |
if x.is_valid_divisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#is_valid_divisor().() => 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(). &value /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). &x, |
| 422 |
else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 423 |
} |
| 424 |
}, |
| 425 |
else => { |
| 426 |
let denom = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0) -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). &x; |
| 427 |
lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 428 |
if denom.is_valid_divisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#is_valid_divisor().() => 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(). &value /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). denom, |
| 429 |
else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 430 |
} |
| 431 |
}, |
| 432 |
}; |
| 433 |
|
| 434 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# { |
| 435 |
huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., |
| 436 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., |
| 437 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.: x 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::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0), |
| 438 |
standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 439 |
} |
| 440 |
} |
| 441 |
} |
| 442 |
|
| 443 |
impl_tuple_conversion_huerust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> as (H, T, T), RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#); |
| 444 |
|
| 445 |
impl_is_within_boundsrust-analyzer cargo palette 0.7.6 macros/clamp/impl_is_within_bounds!! { |
| 446 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> { |
| 447 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation. => [Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][IsWithinBounds]::min_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][IsWithinBounds]::max_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_saturation().()], |
| 448 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness. => [Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][IsWithinBounds]::min_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_lightness().(), Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][IsWithinBounds]::max_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_lightness().()] |
| 449 |
} |
| 450 |
where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus# |
| 451 |
} |
| 452 |
impl_clamprust-analyzer cargo palette 0.7.6 macros/clamp/impl_clamp!! { |
| 453 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> { |
| 454 |
saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation. => [Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][ClampAssign]::min_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][ClampAssign]::max_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_saturation().()], |
| 455 |
lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness. => [Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][ClampAssign]::min_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_lightness().(), Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][ClampAssign]::max_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_lightness().()] |
| 456 |
} |
| 457 |
other {huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.} |
| 458 |
where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus# |
| 459 |
} |
| 460 |
|
| 461 |
impl_mix_huerust-analyzer cargo palette 0.7.6 macros/mix/impl_mix_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> {saturation, lightness} phantom: standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 462 |
impl_lightenrust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_lighten!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> increase {lightness => [Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Lighten]::min_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_lightness().(), Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Lighten]::max_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_lightness().()]} other {huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.} phantom: standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard. where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#); |
| 463 |
impl_saturaterust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_saturate!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> increase {saturation => [Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Saturate]::min_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Saturate]::max_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_saturation().()]} other {huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.} phantom: standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard. where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#); |
| 464 |
impl_hue_opsrust-analyzer cargo palette 0.7.6 macros/hue/impl_hue_ops!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#); |
| 465 |
|
| 466 |
impl<S, T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> |
| 467 |
where |
| 468 |
T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, |
| 469 |
{ |
| 470 |
type Maskrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#; |
| 471 |
} |
| 472 |
|
| 473 |
impl<S, T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> |
| 474 |
where |
| 475 |
T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 476 |
RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 477 |
{ |
| 478 |
fn defaultrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Default]default().() -> Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> { |
| 479 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new().( |
| 480 |
RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), |
| 481 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Default]::min_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_saturation().(), |
| 482 |
Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][Default]::min_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_lightness().(), |
| 483 |
) |
| 484 |
} |
| 485 |
} |
| 486 |
|
| 487 |
impl_color_addrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_add!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, [huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 488 |
impl_color_subrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_sub!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, [huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 489 |
|
| 490 |
impl_array_castsrust-analyzer cargo palette 0.7.6 macros/casting/impl_array_casts!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>, [T; 3]); |
| 491 |
impl_simd_array_conversion_huerust-analyzer cargo palette 0.7.6 macros/simd/impl_simd_array_conversion_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, [saturation, lightness], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 492 |
impl_struct_of_array_traits_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_array_traits_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, RgbHueIterrust-analyzer cargo palette 0.7.6 hues/RgbHueIter#, [saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 493 |
|
| 494 |
impl_eq_huerust-analyzer cargo palette 0.7.6 macros/equality/impl_eq_hue!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, [huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.]); |
| 495 |
impl_copy_clonerust-analyzer cargo palette 0.7.6 macros/copy_clone/impl_copy_clone!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S>, [huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue., saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.], standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.); |
| 496 |
|
| 497 |
#[allow(deprecated)] |
| 498 |
impl<S, T> craterust-analyzer cargo palette 0.7.6 crate/::RelativeContrastrust-analyzer cargo palette 0.7.6 relative_contrast/RelativeContrast# for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> |
| 499 |
where |
| 500 |
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#, |
| 501 |
T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>, |
| 502 |
S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#, |
| 503 |
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 hsl/impl#[`Hsl<S, T>`][RelativeContrast]>, |
| 504 |
{ |
| 505 |
type Scalarrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][RelativeContrast]Scalar# = T; |
| 506 |
|
| 507 |
#[inline] |
| 508 |
fn get_contrast_ratiorust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][RelativeContrast]get_contrast_ratio().(self, other: Selfrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`][RelativeContrast]) -> T { |
| 509 |
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); |
| 510 |
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); |
| 511 |
|
| 512 |
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.) |
| 513 |
} |
| 514 |
} |
| 515 |
|
| 516 |
impl_rand_traits_hsl_biconerust-analyzer cargo palette 0.7.6 macros/random/impl_rand_traits_hsl_bicone!!( |
| 517 |
UniformHslrust-analyzer cargo palette 0.7.6 hsl/UniformHsl#, |
| 518 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S> { |
| 519 |
hue: UniformRgbHuerust-analyzer cargo palette 0.7.6 hues/UniformRgbHue# => RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, |
| 520 |
height: lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness., |
| 521 |
radius: saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation. |
| 522 |
} |
| 523 |
phantom: standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard.: PhantomData<S> |
| 524 |
); |
| 525 |
|
| 526 |
#[cfg(feature = "bytemuck")] |
| 527 |
unsafe impl<S, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {} |
| 528 |
|
| 529 |
#[cfg(feature = "bytemuck")] |
| 530 |
unsafe impl<S: 'static, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {} |
| 531 |
|
| 532 |
#[cfg(test)] |
| 533 |
mod testrust-analyzer cargo palette 0.7.6 hsl/test/ { |
| 534 |
use superrust-analyzer cargo palette 0.7.6 hsl/::Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#; |
| 535 |
|
| 536 |
test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#); |
| 537 |
|
| 538 |
#[cfg(feature = "approx")] |
| 539 |
mod conversionrust-analyzer cargo palette 0.7.6 hsl/test/conversion/ { |
| 540 |
use craterust-analyzer cargo palette 0.7.6 crate/::{FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#, Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#, Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#}; |
| 541 |
|
| 542 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 543 |
fn redrust-analyzer cargo palette 0.7.6 hsl/test/conversion/red().() { |
| 544 |
let a = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::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)); |
| 545 |
let b = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(0.0, 1.0, 0.5); |
| 546 |
let c = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(0.0, 1.0, 1.0)); |
| 547 |
|
| 548 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 549 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c); |
| 550 |
} |
| 551 |
|
| 552 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 553 |
fn orangerust-analyzer cargo palette 0.7.6 hsl/test/conversion/orange().() { |
| 554 |
let a = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::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)); |
| 555 |
let b = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(30.0, 1.0, 0.5); |
| 556 |
let c = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(30.0, 1.0, 1.0)); |
| 557 |
|
| 558 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 559 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c); |
| 560 |
} |
| 561 |
|
| 562 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 563 |
fn greenrust-analyzer cargo palette 0.7.6 hsl/test/conversion/green().() { |
| 564 |
let a = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::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)); |
| 565 |
let b = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(120.0, 1.0, 0.5); |
| 566 |
let c = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(120.0, 1.0, 1.0)); |
| 567 |
|
| 568 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 569 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c); |
| 570 |
} |
| 571 |
|
| 572 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 573 |
fn bluerust-analyzer cargo palette 0.7.6 hsl/test/conversion/blue().() { |
| 574 |
let a = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::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)); |
| 575 |
let b = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(240.0, 1.0, 0.5); |
| 576 |
let c = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(240.0, 1.0, 1.0)); |
| 577 |
|
| 578 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 579 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c); |
| 580 |
} |
| 581 |
|
| 582 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 583 |
fn purplerust-analyzer cargo palette 0.7.6 hsl/test/conversion/purple().() { |
| 584 |
let a = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::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)); |
| 585 |
let b = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(270.0, 1.0, 0.5); |
| 586 |
let c = Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(270.0, 1.0, 1.0)); |
| 587 |
|
| 588 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b); |
| 589 |
assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c); |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 594 |
fn rangesrust-analyzer cargo palette 0.7.6 hsl/test/ranges().() { |
| 595 |
assert_rangesrust-analyzer cargo palette 0.7.6 macros/clamp/assert_ranges!! { |
| 596 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<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#, f64>; |
| 597 |
clamped { |
| 598 |
saturation: 0.0 => 1.0, |
| 599 |
lightness: 0.0 => 1.0 |
| 600 |
} |
| 601 |
clamped_min {} |
| 602 |
unclamped { |
| 603 |
hue: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().360.0 => 360.0 |
| 604 |
} |
| 605 |
} |
| 606 |
} |
| 607 |
|
| 608 |
raw_pixel_conversion_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_tests!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<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, saturation, lightness); |
| 609 |
raw_pixel_conversion_fail_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_fail_tests!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<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, saturation, lightness); |
| 610 |
|
| 611 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 612 |
fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 hsl/test/check_min_max_components().() { |
| 613 |
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#; |
| 614 |
|
| 615 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::min_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_saturation().(), 0.0); |
| 616 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::min_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]min_lightness().(), 0.0); |
| 617 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::max_saturationrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_saturation().(), 1.0); |
| 618 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::max_lightnessrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]max_lightness().(), 1.0); |
| 619 |
} |
| 620 |
|
| 621 |
struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!( |
| 622 |
Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<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 hsl/Hsl#hue., saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation., lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.] phantom: standardrust-analyzer cargo palette 0.7.6 hsl/Hsl#standard., |
| 623 |
superrust-analyzer cargo palette 0.7.6 hsl/::Hslarust-analyzer cargo palette 0.7.6 hsl/Hsla#::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4), |
| 624 |
superrust-analyzer cargo palette 0.7.6 hsl/::Hslarust-analyzer cargo palette 0.7.6 hsl/Hsla#::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new().(0.2, 0.3, 0.4, 0.5), |
| 625 |
superrust-analyzer cargo palette 0.7.6 hsl/::Hslarust-analyzer cargo palette 0.7.6 hsl/Hsla#::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Alpha<Hsl<S, T>, A>`]new().(0.3, 0.4, 0.5, 0.6) |
| 626 |
); |
| 627 |
|
| 628 |
#[cfg(feature = "serializing")] |
| 629 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 630 |
fn serializerust-analyzer cargo palette 0.7.6 hsl/test/serialize().() { |
| 631 |
let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<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().(); |
| 632 |
|
| 633 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 634 |
serialized, |
| 635 |
r#"{"hue":0.3,"saturation":0.8,"lightness":0.1}"# |
| 636 |
); |
| 637 |
} |
| 638 |
|
| 639 |
#[cfg(feature = "serializing")] |
| 640 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 641 |
fn deserializerust-analyzer cargo palette 0.7.6 hsl/test/deserialize().() { |
| 642 |
let deserialized: Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl# = |
| 643 |
::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,"saturation":0.8,"lightness":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 644 |
|
| 645 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::newrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<S, T>`]new().(0.3, 0.8, 0.1)); |
| 646 |
} |
| 647 |
|
| 648 |
test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! { |
| 649 |
Hsl<crate::encoding::Srgb, f32> as crate::rgb::Rgb { |
| 650 |
red: (0.0, 1.0), |
| 651 |
green: (0.0, 1.0), |
| 652 |
blue: (0.0, 1.0) |
| 653 |
}, |
| 654 |
min: Hsl::new(0.0f32, 0.0, 0.0), |
| 655 |
max: Hsl::new(360.0, 1.0, 1.0) |
| 656 |
} |
| 657 |
|
| •658 |
/* |
| 659 |
/// Sanity check to make sure the test doesn't start accepting known |
| 660 |
/// non-uniform distributions. |
| 661 |
#[cfg(feature = "random")] |
| 662 |
#[test] |
| 663 |
#[should_panic(expected = "is not uniform enough")] |
| 664 |
fn uniform_distribution_fail() { |
| 665 |
use rand::Rng; |
| 666 |
|
| 667 |
const BINS: usize = crate::random_sampling::test_utils::BINS; |
| 668 |
const SAMPLES: usize = crate::random_sampling::test_utils::SAMPLES; |
| 669 |
|
| 670 |
let mut red = [0; BINS]; |
| 671 |
let mut green = [0; BINS]; |
| 672 |
let mut blue = [0; BINS]; |
| 673 |
|
| 674 |
let mut rng = rand_mt::Mt::new(1234); // We want the same seed on every run to avoid random fails |
| 675 |
|
| 676 |
for _ in 0..SAMPLES { |
| 677 |
let color = Hsl::<crate::encoding::Srgb, f32>::new( |
| 678 |
rng.gen::<f32>() * 360.0, |
| 679 |
rng.gen(), |
| 680 |
rng.gen(), |
| 681 |
); |
| 682 |
let color: crate::rgb::Rgb = crate::IntoColor::into_color(color); |
| 683 |
red[((color.red * BINS as f32) as usize).min(9)] += 1; |
| 684 |
green[((color.green * BINS as f32) as usize).min(9)] += 1; |
| 685 |
blue[((color.blue * BINS as f32) as usize).min(9)] += 1; |
| 686 |
} |
| 687 |
|
| 688 |
assert_uniform_distribution!(red); |
| 689 |
assert_uniform_distribution!(green); |
| 690 |
assert_uniform_distribution!(blue); |
| 691 |
} |
| •692 |
*/ |
| 693 |
} |