| 1 | //! Types for the RGB color space, including spaces and standards. |
| 2 | //! |
| 3 | //! # Linear And Non-linear RGB |
| 4 | //! |
| 5 | //! Colors in images are often "gamma corrected", or converted using some |
| 6 | //! non-linear transfer function into a format like sRGB before being stored or |
| 7 | //! displayed. This is done as a compression method and to prevent banding; it's |
| 8 | //! also a bit of a legacy from the ages of the CRT monitors, where the output |
| 9 | //! from the electron gun was non-linear. The problem is that these formats are |
| 10 | //! *non-linear color spaces*, which means that many operations that you may |
| 11 | //! want to perform on colors (addition, subtraction, multiplication, linear |
| 12 | //! interpolation, etc.) will work unexpectedly when performed in such a |
| 13 | //! non-linear color space. Thus, the compression has to be reverted to restore |
| 14 | //! linearity and ensure that many operations on the colors behave as expected. |
| 15 | //! |
| 16 | //! But, even when colors *are* 'linear', there is yet more to explore. |
| 17 | //! |
| 18 | //! The most common way that colors are defined, especially for computer |
| 19 | //! storage, is in terms of so-called *tristimulus values*, meaning that all |
| 20 | //! colors can be represented as a vector of three values. |
| 21 | //! The reason colors can generally be stored as only a three-dimensional |
| 22 | //! vector, and not an *N*-dimensional one, where *N* is some number of possible |
| 23 | //! wavelengths of light, is because our eyes contain only three types of cones. |
| 24 | //! Each of these cones has its own sensitivity curve in response to the |
| 25 | //! wavelengths of visible light, giving us three "dimensions" of sensitivity to color. |
| 26 | //! These cones are often called the L, M, and S (for long, medium, and short) |
| 27 | //! cones, and their sensitivity curves *roughly* position them as most |
| 28 | //! sensitive to "red", "green", and "blue" parts of the spectrum. As such, we |
| 29 | //! can choose only three values to represent any possible color that a human is |
| 30 | //! able to see. An interesting consequence of this is that humans can see two |
| 31 | //! different objects which are emitting *completely different actual light |
| 32 | //! spectra* as the *exact same perceptual color* so long as those wavelengths, |
| 33 | //! when transformed by the sensitivity curves of our cones, end up resulting in |
| 34 | //! the same L, M, and S values sent to our brains. |
| 35 | //! |
| 36 | //! A **color space** (which simply refers to a set of standards by which we map |
| 37 | //! a set of arbitrary values to real-world colors) which uses tristimulus |
| 38 | //! values is often defined in terms of |
| 39 | //! |
| 40 | //! 1. Its **primaries** |
| 41 | //! 2. Its **reference white** or **white point** |
| 42 | //! |
| 43 | //! The **primaries** together represent the total *gamut* (i.e. displayable |
| 44 | //! range of colors) of that color space. The **white point** defines a |
| 45 | //! concrete tristimulus value that corresponds to a real, physical white |
| 46 | //! reflecting object being lit by a known light source and observed by the |
| 47 | //! 'standard observer' (i.e. a standardized model of human color perception). |
| 48 | //! |
| 49 | //! The informal "RGB" color space is such a tristimulus color space, since it |
| 50 | //! is defined by three values, but it is underspecified since we don't know |
| 51 | //! which primaries are being used (i.e. how exactly are the canonical "red", |
| 52 | //! "green", and "blue" defined?), nor its white point. In most cases, when |
| 53 | //! people talk about "RGB" or "Linear RGB" colors, what they are *actually* |
| 54 | //! talking about is the "Linear sRGB" color space, which uses the primaries and |
| 55 | //! white point defined in the sRGB standard, but which *does not* have the |
| 56 | //! (non-linear) sRGB *transfer function* applied. |
| 57 | //! |
| 58 | //! Palette takes these details into account and encodes them as type |
| 59 | //! parameters, with sRGB as the default. The goal is to make it easy to use |
| 60 | //! colors correctly and still allow advanced users a high degree of |
| 61 | //! flexibility. |
| 62 | |
| 63 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 64 | encodingrust-analyzer cargo palette 0.7.6 encoding/::{selfrust-analyzer cargo palette 0.7.6 encoding/, FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#, Gammarust-analyzer cargo palette 0.7.6 encoding/gamma/Gamma#, IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#, Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#}, |
| 65 | 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#}, |
| 66 | white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, |
| 67 | Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#, Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#, |
| 68 | }; |
| 69 | |
| 70 | pub use selfrust-analyzer cargo palette 0.7.6 rgb/::rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/::{FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#, Iterrust-analyzer cargo palette 0.7.6 rgb/rgb/Iter#, Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#}; |
| 71 | |
| 72 | pub mod channelsrust-analyzer cargo palette 0.7.6 rgb/channels/; |
| 73 | #[allow(clippy::module_inception)] |
| 74 | mod rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/; |
| 75 | |
| 76 | /// Non-linear sRGB, the most common RGB input/output format. |
| 77 | /// |
| 78 | /// If you are looking for "just RGB", this is probably it. This type alias |
| 79 | /// helps by locking the more generic [`Rgb`] type to the sRGB format. |
| 80 | /// |
| 81 | /// See [`Rgb`] for more details on how to create a value and use it. |
| 82 | pub type Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<T = f32> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T>; |
| 83 | |
| 84 | /// Non-linear sRGB with an alpha component. |
| 85 | /// |
| 86 | /// This is a transparent version of [`Srgb`], which is commonly used as the |
| 87 | /// input or output format. If you are looking for "just RGBA", this is probably |
| 88 | /// it. |
| 89 | /// |
| 90 | /// See [`Rgb`], [`Rgba`] and [`Alpha`](crate::Alpha) for more details on how to |
| 91 | /// create a value and use it. |
| 92 | pub type Srgbarust-analyzer cargo palette 0.7.6 rgb/Srgba#<T = f32> = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T>; |
| 93 | |
| 94 | /// Linear sRGB. |
| 95 | /// |
| 96 | /// You probably want [`Srgb`] if you are looking for an input or output format |
| 97 | /// (or "just RGB"). This is the linear version of sRGB, which is what you would |
| 98 | /// usually convert to before working with the color. |
| 99 | /// |
| 100 | /// See [`Rgb`] for more details on how to create a value and use it. |
| 101 | #[doc(alias = "linear")] |
| 102 | pub type LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T = f32> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>, T>; |
| 103 | |
| 104 | /// Linear sRGB with an alpha component. |
| 105 | /// |
| 106 | /// You probably want [`Srgba`] if you are looking for an input or output format |
| 107 | /// (or "just RGB"). This is the linear version of sRGBA, which is what you |
| 108 | /// would usually convert to before working with the color. |
| 109 | /// |
| 110 | /// See [`Rgb`], [`Rgba`] and [`Alpha`](crate::Alpha) for more details on how to |
| 111 | /// create a value and use it. |
| 112 | #[doc(alias = "linear")] |
| 113 | pub type LinSrgbarust-analyzer cargo palette 0.7.6 rgb/LinSrgba#<T = f32> = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>, T>; |
| 114 | |
| 115 | /// Gamma 2.2 encoded sRGB. |
| 116 | /// |
| 117 | /// This is similar to [`Srgb`], but uses the exponent function as an |
| 118 | /// approximation. It's a common trick to speed up conversion when accuracy can |
| 119 | /// be sacrificed. It's still faster to use `Srgb` when also converting to and |
| 120 | /// from `u8` at the same time. |
| 121 | /// |
| 122 | /// See [`Rgb`] for more details on how to create a value and use it. |
| 123 | pub type GammaSrgbrust-analyzer cargo palette 0.7.6 rgb/GammaSrgb#<T = f32> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Gammarust-analyzer cargo palette 0.7.6 encoding/gamma/Gamma#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>, T>; |
| 124 | |
| 125 | /// Gamma 2.2 encoded sRGB with an alpha component. |
| 126 | /// |
| 127 | /// This is similar to [`Srgba`], but uses the exponent function as an |
| 128 | /// approximation. It's a common trick to speed up conversion when accuracy can |
| 129 | /// be sacrificed. It's still faster to use `Srgba` when also converting to and |
| 130 | /// from `u8` at the same time. |
| 131 | /// |
| 132 | /// See [`Rgb`], [`Rgba`] and [`Alpha`](crate::Alpha) for more details on how to |
| 133 | /// create a value and use it. |
| 134 | pub type GammaSrgbarust-analyzer cargo palette 0.7.6 rgb/GammaSrgba#<T = f32> = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<Gammarust-analyzer cargo palette 0.7.6 encoding/gamma/Gamma#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>, T>; |
| 135 | |
| 136 | /// An RGB space and a transfer function. |
| 137 | pub trait RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# { |
| 138 | /// The RGB color space. |
| 139 | type Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#; |
| 140 | |
| 141 | /// The transfer function for the color components. |
| 142 | type TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#; |
| 143 | } |
| 144 | |
| 145 | impl<Sp, Tf> RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# for (Sp, Tf) |
| 146 | where |
| 147 | Sp: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, |
| 148 | { |
| 149 | type Spacerust-analyzer cargo palette 0.7.6 rgb/impl#[`(Sp, Tf)`][RgbStandard]Space# = Sp; |
| 150 | type TransferFnrust-analyzer cargo palette 0.7.6 rgb/impl#[`(Sp, Tf)`][RgbStandard]TransferFn# = Tf; |
| 151 | } |
| 152 | |
| 153 | impl<Pr, Wp, Tf> RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# for (Pr, Wp, Tf) |
| 154 | where |
| 155 | (Pr, Wp): RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, |
| 156 | { |
| 157 | type Spacerust-analyzer cargo palette 0.7.6 rgb/impl#[`(Pr, Wp, Tf)`][RgbStandard]Space# = (Pr, Wp); |
| 158 | type TransferFnrust-analyzer cargo palette 0.7.6 rgb/impl#[`(Pr, Wp, Tf)`][RgbStandard]TransferFn# = Tf; |
| 159 | } |
| 160 | |
| 161 | /// A set of primaries and a white point. |
| 162 | pub trait RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace# { |
| 163 | /// The primaries of the RGB color space. |
| 164 | type Primariesrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#Primaries#; |
| 165 | |
| 166 | /// The white point of the RGB color space. |
| 167 | type WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#; |
| 168 | |
| 169 | /// Get a pre-defined matrix for converting an RGB value with this standard |
| 170 | /// into an XYZ value. |
| 171 | /// |
| 172 | /// Returning `None` (as in the default implementation) means that the |
| 173 | /// matrix will be computed dynamically, which is significantly slower. |
| 174 | #[inline(always)] |
| 175 | fn rgb_to_xyz_matrixrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#rgb_to_xyz_matrix().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#<f64>> { |
| 176 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 177 | } |
| 178 | |
| 179 | /// Get a pre-defined matrix for converting an XYZ value into an RGB value |
| 180 | /// with this standard. |
| 181 | /// |
| 182 | /// Returning `None` (as in the default implementation) means that the |
| 183 | /// matrix will be computed dynamically, which is significantly slower. |
| 184 | #[inline(always)] |
| 185 | fn xyz_to_rgb_matrixrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#xyz_to_rgb_matrix().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#<f64>> { |
| 186 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | impl<P, W> RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace# for (P, W) { |
| 191 | type Primariesrust-analyzer cargo palette 0.7.6 rgb/impl#[`(P, W)`][RgbSpace]Primaries# = P; |
| 192 | type WhitePointrust-analyzer cargo palette 0.7.6 rgb/impl#[`(P, W)`][RgbSpace]WhitePoint# = W; |
| 193 | } |
| 194 | |
| 195 | /// Represents the red, green and blue primaries of an RGB space. |
| 196 | pub trait Primariesrust-analyzer cargo palette 0.7.6 rgb/Primaries#<T> { |
| 197 | /// Primary red. |
| 198 | fn redrust-analyzer cargo palette 0.7.6 rgb/Primaries#red().() -> Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>; |
| 199 | /// Primary green. |
| 200 | fn greenrust-analyzer cargo palette 0.7.6 rgb/Primaries#green().() -> Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>; |
| 201 | /// Primary blue. |
| 202 | fn bluerust-analyzer cargo palette 0.7.6 rgb/Primaries#blue().() -> Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>; |
| 203 | } |
| 204 | |
| 205 | impl<T, U> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>> for Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<U> |
| 206 | where |
| 207 | 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#: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = 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#> + FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, U>, |
| 208 | { |
| 209 | #[inline] |
| 210 | fn fromrust-analyzer cargo palette 0.7.6 rgb/impl#[`Rgb<encoding::Srgb, U>`][`From<Rgb<Linear<encoding::Srgb>, T>>`]from().(lin_srgb: LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/impl#[`Rgb<encoding::Srgb, U>`][`From<Rgb<Linear<encoding::Srgb>, T>>`] { |
| 211 | lin_srgb.into_encodingrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<Linear<S>, T>`]into_encoding().() |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | impl<T, U> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<T>> for LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<U> |
| 216 | where |
| 217 | 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#: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = 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#> + IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<U, T>, |
| 218 | { |
| 219 | #[inline] |
| 220 | fn fromrust-analyzer cargo palette 0.7.6 rgb/impl#[`Rgb<Linear<encoding::Srgb>, U>`][`From<Rgb<encoding::Srgb, T>>`]from().(srgb: Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/impl#[`Rgb<Linear<encoding::Srgb>, U>`][`From<Rgb<encoding::Srgb, T>>`] { |
| 221 | srgb.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().() |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | impl<T, U> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>> for Srgbarust-analyzer cargo palette 0.7.6 rgb/Srgba#<U> |
| 226 | where |
| 227 | U: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 228 | 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#: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = 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#> + FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, U>, |
| 229 | { |
| 230 | #[inline] |
| 231 | fn fromrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<encoding::Srgb, U>, U>`][`From<Rgb<Linear<encoding::Srgb>, T>>`]from().(lin_srgb: LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<encoding::Srgb, U>, U>`][`From<Rgb<Linear<encoding::Srgb>, T>>`] { |
| 232 | let non_lin = Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().(lin_srgb); |
| 233 | non_lin.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | impl<T, U> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LinSrgbarust-analyzer cargo palette 0.7.6 rgb/LinSrgba#<T>> for Srgbarust-analyzer cargo palette 0.7.6 rgb/Srgba#<U> |
| 238 | where |
| 239 | U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T>, |
| 240 | 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#: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = 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#> + FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, U>, |
| 241 | { |
| 242 | #[inline] |
| 243 | fn fromrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<encoding::Srgb, U>, U>`][`From<crate::Alpha<Rgb<Linear<encoding::Srgb>, T>, T>>`]from().(lin_srgba: LinSrgbarust-analyzer cargo palette 0.7.6 rgb/LinSrgba#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<encoding::Srgb, U>, U>`][`From<crate::Alpha<Rgb<Linear<encoding::Srgb>, T>, T>>`] { |
| 244 | Srgbarust-analyzer cargo palette 0.7.6 rgb/Srgba#::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]from_linear().(lin_srgba) |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | impl<T, U> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<T>> for LinSrgbarust-analyzer cargo palette 0.7.6 rgb/LinSrgba#<U> |
| 249 | where |
| 250 | U: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 251 | 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#: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = 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#> + IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<U, T>, |
| 252 | { |
| 253 | #[inline] |
| 254 | fn fromrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<Linear<encoding::Srgb>, U>, U>`][`From<Rgb<encoding::Srgb, T>>`]from().(srgb: Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<Linear<encoding::Srgb>, U>, U>`][`From<Rgb<encoding::Srgb, T>>`] { |
| 255 | srgb.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | impl<T, U> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Srgbarust-analyzer cargo palette 0.7.6 rgb/Srgba#<T>> for LinSrgbarust-analyzer cargo palette 0.7.6 rgb/LinSrgba#<U> |
| 260 | where |
| 261 | U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T>, |
| 262 | 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#: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = 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#> + IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<U, T>, |
| 263 | { |
| 264 | #[inline] |
| 265 | fn fromrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<Linear<encoding::Srgb>, U>, U>`][`From<crate::Alpha<Rgb<encoding::Srgb, T>, T>>`]from().(srgba: Srgbarust-analyzer cargo palette 0.7.6 rgb/Srgba#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/impl#[`crate::Alpha<Rgb<Linear<encoding::Srgb>, U>, U>`][`From<crate::Alpha<Rgb<encoding::Srgb, T>, T>>`] { |
| 266 | srgba.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_linear().() |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /// A packed representation of RGBA in RGBA order. |
| 271 | pub type PackedRgbarust-analyzer cargo palette 0.7.6 rgb/PackedRgba#<P = u32> = craterust-analyzer cargo palette 0.7.6 crate/::castrust-analyzer cargo palette 0.7.6 cast/::Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Rgbarust-analyzer cargo palette 0.7.6 rgb/channels/Rgba#, P>; |
| 272 | |
| 273 | /// A packed representation of RGBA in ARGB order. |
| 274 | pub type PackedArgbrust-analyzer cargo palette 0.7.6 rgb/PackedArgb#<P = u32> = craterust-analyzer cargo palette 0.7.6 crate/::castrust-analyzer cargo palette 0.7.6 cast/::Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Argbrust-analyzer cargo palette 0.7.6 rgb/channels/Argb#, P>; |
| 275 | |
| 276 | /// A packed representation of RGBA in BGRA order. |
| 277 | pub type PackedBgrarust-analyzer cargo palette 0.7.6 rgb/PackedBgra#<P = u32> = craterust-analyzer cargo palette 0.7.6 crate/::castrust-analyzer cargo palette 0.7.6 cast/::Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Bgrarust-analyzer cargo palette 0.7.6 rgb/channels/Bgra#, P>; |
| 278 | |
| 279 | /// A packed representation of RGBA in ABGR order. |
| 280 | pub type PackedAbgrrust-analyzer cargo palette 0.7.6 rgb/PackedAbgr#<P = u32> = craterust-analyzer cargo palette 0.7.6 crate/::castrust-analyzer cargo palette 0.7.6 cast/::Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Abgrrust-analyzer cargo palette 0.7.6 rgb/channels/Abgr#, P>; |