Debian Codegraph @

src/cam16/parameters.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::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#;
2
3 use craterust-analyzer cargo palette 0.7.6 crate/::{
4 bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#,
5 numrust-analyzer cargo palette 0.7.6 num/::{
6 Absrust-analyzer cargo palette 0.7.6 num/Abs#, Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, Clamprust-analyzer cargo palette 0.7.6 num/Clamp#, Exprust-analyzer cargo palette 0.7.6 num/Exp#, FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#, Onerust-analyzer cargo palette 0.7.6 num/One#, PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, Powfrust-analyzer cargo palette 0.7.6 num/Powf#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Signumrust-analyzer cargo palette 0.7.6 num/Signum#, Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#,
7 },
8 white_pointrust-analyzer cargo palette 0.7.6 white_point/::{selfrust-analyzer cargo palette 0.7.6 white_point/, WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#},
9 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#,
10 };
11
12 /// Parameters for CAM16 that describe the viewing conditions.
13 ///
14 /// These parameters describe the viewing conditions for a more accurate color
15 /// appearance metric. The CAM16 attributes and derived values are only really
16 /// comparable if they were calculated with the same parameters. The parameters
17 /// are, however, too dynamic to all be part of the type parameters of
18 /// [`Cam16`][super::Cam16].
19 ///
20 /// The default values are mostly a "blank slate", with a couple of educated
21 /// guesses. Be sure to at least customize the luminances according to the
22 /// expected environment:
23 ///
24 /// ```
25 /// use palette::{Srgb, Xyz, IntoColor, cam16::{Parameters, Surround, Cam16}};
26 ///
27 /// // 40 nits, 50% background luminance and a dim surrounding:
28 /// let mut example_parameters = Parameters::default_static_wp(40.0);
29 /// example_parameters.background_luminance = 0.5;
30 /// example_parameters.surround = Surround::Dim;
31 ///
32 /// let example_color_xyz = Srgb::from(0x5588cc).into_linear().into_color();
33 /// let cam16: Cam16<f64> = Cam16::from_xyz(example_color_xyz, example_parameters);
34 /// ```
35 ///
36 /// See also Moroney (2000) [Usage Guidelines for CIECAM97s][moroney_2000] for
37 /// more information and advice on how to customize these parameters.
38 ///
39 /// [moroney_2000]:
40 /// https://www.imaging.org/common/uploaded%20files/pdfs/Papers/2000/PICS-0-81/1611.pdf
41 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
42 #[non_exhaustive]
43 pub struct Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<WpParam, T> {
44 /// White point of the test illuminant, *X<sub>w</sub>* *Y<sub>w</sub>*
45 /// *Z<sub>w</sub>*. *Y<sub>w</sub>* should be normalized to 1.0.
46 ///
47 /// Defaults to `Wp` when it implements [`WhitePoint`]. It can also be set
48 /// to a custom value if `Wp` results in the wrong white point.
49 pub white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#white_point.: WpParam,
50
51 /// The average luminance of the environment (test adapting field)
52 /// (*L<sub>A</sub>*) in *cd/m<sup>2</sup>* (nits).
53 ///
54 /// Under a “gray world” assumption this is 20% of the luminance of the
55 /// reference white.
56 pub adapting_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#adapting_luminance.: T,
57
58 /// The luminance factor of the background (*Y<sub>b</sub>*), on a scale
59 /// from `0.0` to `1.0` (relative to *Y<sub>w</sub>* = 1.0).
60 ///
61 /// Defaults to `0.2`, medium grey.
62 pub background_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#background_luminance.: T,
63
64 /// A description of the peripheral area, with a value from 0% to 20%. Any
65 /// value outside that range will be clamped to 0% or 20%. It has presets
66 /// for "dark", "dim" and "average".
67 ///
68 /// Defaults to "average" (20%).
69 pub surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#surround.: Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#<T>,
70
71 /// The degree of discounting of (or adaptation to) the reference
72 /// illuminant. Defaults to `Auto`, making the degree of discounting depend
73 /// on the other parameters, but can be customized if necessary.
74 pub discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#discounting.: Discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#<T>,
75 }
76
77 impl<WpParam, T> Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<WpParam, T>
78 where
79 WpParam: WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#<T>,
80 {
81 fn into_any_white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<WpParam, T>`]into_any_white_point().(self) -> Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>, T> {
82 Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters# {
83 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#white_point.: self.white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#white_point..into_xyzrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#into_xyz().(),
84 adapting_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#adapting_luminance.: self.adapting_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#adapting_luminance.,
85 background_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#background_luminance.: self.background_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#background_luminance.,
86 surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#surround.: self.surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#surround.,
87 discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#discounting.: self.discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#discounting.,
88 }
89 }
90 }
91
92 impl<Wp, T> Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#<Wp>, T> {
93 /// Creates a new set of parameters with a static white point and their
94 /// default values set.
95 ///
96 /// These parameters may need to be further customized according to the
97 /// viewing conditions.
98 #[inline]
99 pub fn default_static_wprust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<StaticWp<Wp>, T>`]default_static_wp().(adapting_luminance: T) -> Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<StaticWp<Wp>, T>`]
100 where
101 T: Realrust-analyzer cargo palette 0.7.6 num/Real#,
102 {
103 Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<StaticWp<Wp>, T>`] {
104 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#white_point.: StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#),
105 adapting_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#adapting_luminance.,
106 background_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#background_luminance.: T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2),
107 surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#surround.: Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Averagerust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Average#,
108 discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#discounting.: Discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#::Autorust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#Auto#,
109 }
110 }
111 }
112
113 impl<T> Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>, T> {
114 /// Creates a new set of parameters with a dynamic white point and their
115 /// default values set.
116 ///
117 /// These parameters may need to be further customized according to the
118 /// viewing conditions.
119 #[inline]
120 pub fn default_dynamic_wprust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<Xyz<white_point::Any, T>, T>`]default_dynamic_wp().(white_point: Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>, adapting_luminance: T) -> Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<Xyz<white_point::Any, T>, T>`]
121 where
122 T: Realrust-analyzer cargo palette 0.7.6 num/Real#,
123 {
124 Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<Xyz<white_point::Any, T>, T>`] {
125 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#white_point.,
126 adapting_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#adapting_luminance.,
127 background_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#background_luminance.: T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2),
128 surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#surround.: Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Averagerust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Average#,
129 discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#discounting.: Discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#::Autorust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#Auto#,
130 }
131 }
132 }
133
134 impl<WpParam, T> Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<WpParam, T> {
135 /// Pre-bakes the parameters to avoid repeating parts of the calculaitons
136 /// when converting to and from CAM16.
137 pub fn bakerust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<WpParam, T>`]bake().(self) -> BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, T>
138 where
139 BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, T>: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<WpParam, T>`]>,
140 {
141 self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
142 }
143 }
144
145 #[cfg(all(test, feature = "approx"))]
146 impl<Wp> Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#<Wp>, f64> {
147 /// Only used in unit tests and corresponds to the defaults from https://observablehq.com/@jrus/cam16.
148 pub(craterust-analyzer cargo palette 0.7.6 crate/) const TEST_DEFAULTSrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<StaticWp<Wp>, f64>`]TEST_DEFAULTS.: Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<StaticWp<Wp>, f64>`] = Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<StaticWp<Wp>, f64>`] {
149 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#white_point.: StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#),
150 adapting_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#adapting_luminance.: 40.0f64,
151 background_luminancerust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#background_luminance.: 0.2f64, // 20 / 100, since our XYZ is in the range from 0.0 to 1.0
152 surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#surround.: Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Averagerust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Average#,
153 discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#discounting.: Discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#::Autorust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#Auto#,
154 };
155 }
156
157 /// Pre-calculated variables for CAM16, that only depend on the viewing
158 /// conditions.
159 ///
160 /// Derived from [`Parameters`], the `BakedParameters` can help reducing the
161 /// amount of repeated work required for converting multiple colors.
162 pub struct BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, T> {
163 pub(craterust-analyzer cargo palette 0.7.6 crate/) innerrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#inner.: superrust-analyzer cargo palette 0.7.6 cam16/::mathrust-analyzer cargo palette 0.7.6 cam16/math/::DependentParametersrust-analyzer cargo palette 0.7.6 cam16/math/DependentParameters#<T>,
164 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<WpParam>,
165 }
166
167 impl<WpParam, T> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, T>
168 where
169 T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
170 {
171 fn clonerust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`BakedParameters<WpParam, T>`][Clone]clone().(&self) -> Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`BakedParameters<WpParam, T>`][Clone] {
172 Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`BakedParameters<WpParam, T>`][Clone] {
173 innerrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#inner.: self.innerrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#inner..clonerust-analyzer cargo palette 0.7.6 cam16/math/impl#[`DependentParameters<T>`][Clone]clone().(),
174 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
175 }
176 }
177 }
178
179 impl<WpParam, T> Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# for BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, T> where T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {}
180
181 impl<WpParam, T> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<WpParam, T>> for BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, T>
182 where
183 WpParam: WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#<T>,
184 T: Realrust-analyzer cargo palette 0.7.6 num/Real#
185 + FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#<Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar# = T>
186 + Onerust-analyzer cargo palette 0.7.6 num/One#
187 + Zerorust-analyzer cargo palette 0.7.6 num/Zero#
188 + Clamprust-analyzer cargo palette 0.7.6 num/Clamp#
189 + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#
190 + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#
191 + Powfrust-analyzer cargo palette 0.7.6 num/Powf#
192 + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#
193 + Exprust-analyzer cargo palette 0.7.6 num/Exp#
194 + Absrust-analyzer cargo palette 0.7.6 num/Abs#
195 + Signumrust-analyzer cargo palette 0.7.6 num/Signum#
196 + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
197 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>,
198 {
199 fn fromrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`BakedParameters<WpParam, T>`][`From<Parameters<WpParam, T>>`]from().(value: Parametersrust-analyzer cargo palette 0.7.6 cam16/parameters/Parameters#<WpParam, T>) -> Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`BakedParameters<WpParam, T>`][`From<Parameters<WpParam, T>>`] {
200 Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`BakedParameters<WpParam, T>`][`From<Parameters<WpParam, T>>`] {
201 innerrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#inner.: superrust-analyzer cargo palette 0.7.6 cam16/::mathrust-analyzer cargo palette 0.7.6 cam16/math/::prepare_parametersrust-analyzer cargo palette 0.7.6 cam16/math/prepare_parameters().(value.into_any_white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Parameters<WpParam, T>`]into_any_white_point().()),
202 white_pointrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
203 }
204 }
205 }
206
207 /// A description of the peripheral area.
208 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
209 #[non_exhaustive]
210 pub enum Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#<T> {
211 /// Represents a dark room, such as a movie theatre. Corresponds to a
212 /// surround value of 0%.
213 Darkrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Dark#,
214
215 /// Represents a dimly lit room with a bright TV or monitor. Corresponds to
216 /// a surround value of 10%.
217 Dimrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Dim#,
218
219 /// Represents a surface color, such as a print on a 20% reflective,
220 /// uniformly lit background surface. Corresponds to a surround value of
221 /// 20%.
222 Averagerust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Average#,
223
224 /// Any custom value from 0% to 20%. Any value outside that range will be
225 /// clamped to either `0.0` or `20.0`.
226 Percentrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Percent#(T),
227 }
228
229 impl<T> Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#<T> {
230 pub(craterust-analyzer cargo palette 0.7.6 crate/) fn into_percentrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Surround<T>`]into_percent().(self) -> T
231 where
232 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Clamprust-analyzer cargo palette 0.7.6 num/Clamp#,
233 {
234 match self {
235 Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Darkrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Dark# => T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0),
236 Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Dimrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Dim# => T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(10.0),
237 Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Averagerust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Average# => T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(20.0),
238 Surroundrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#::Percentrust-analyzer cargo palette 0.7.6 cam16/parameters/Surround#Percent#(value) => value.clamprust-analyzer cargo palette 0.7.6 num/Clamp#clamp().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(20.0)),
239 }
240 }
241 }
242
243 /// The degree of discounting of (or adaptation to) the illuminant.
244 ///
245 /// See also: <https://en.wikipedia.org/wiki/CIECAM02#CAT02>.
246 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
247 #[non_exhaustive]
248 pub enum Discountingrust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#<T> {
249 /// Uses luminance levels and surround conditions to calculate the
250 /// discounting, using the original CIECAM16 *D* function. Ranges from
251 /// `0.65` to `1.0`.
252 Autorust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#Auto#,
253
254 /// A value between `0.0` and `1.0`, where `0.0` represents no adaptation,
255 /// and `1.0` represents that the observer's vision is fully adapted to the
256 /// illuminant. Values outside that range will be clamped.
257 Customrust-analyzer cargo palette 0.7.6 cam16/parameters/Discounting#Custom#(T),
258 }
259
260 /// A trait for types that can be used as white point parameters in
261 /// [`Parameters`].
262 pub trait WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#<T> {
263 /// The static representation of this white point, or [`white_point::Any`]
264 /// if it's dynamic.
265 type StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#StaticWp#;
266
267 /// Returns the XYZ value for this white point.
268 fn into_xyzrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#into_xyz().(self) -> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T>;
269 }
270
271 impl<T> WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#<T> for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T> {
272 type StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Xyz<white_point::Any, T>`][`WhitePointParameter<T>`]StaticWp# = white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#;
273
274 fn into_xyzrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`Xyz<white_point::Any, T>`][`WhitePointParameter<T>`]into_xyz().(self) -> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T> {
275 self
276 }
277 }
278
279 /// Represents a static white point in [`Parameters`], as opposed to a dynamic
280 /// [`Xyz`] value.
281 pub struct StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#<Wp>(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<Wp>);
282
283 impl<T, Wp> WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#<T> for StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#<Wp>
284 where
285 Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T>,
286 {
287 type StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`StaticWp<Wp>`][`WhitePointParameter<T>`]StaticWp# = Wp;
288
289 fn into_xyzrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`StaticWp<Wp>`][`WhitePointParameter<T>`]into_xyz().(self) -> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<white_pointrust-analyzer cargo palette 0.7.6 white_point/::Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T> {
290 Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().()
291 }
292 }
293
294 impl<Wp> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#<Wp> {
295 fn clonerust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`StaticWp<Wp>`][Clone]clone().(&self) -> Selfrust-analyzer cargo palette 0.7.6 cam16/parameters/impl#[`StaticWp<Wp>`][Clone] {
296 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
297 }
298 }
299
300 impl<Wp> Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# for StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/StaticWp#<Wp> {}