15
15
//! They can be attached to either the item itself, or to the fields.
16
16
//!
17
17
//! ```
18
- //! # use palette::rgb::RgbSpace;
18
+ //! # use palette::rgb::{RgbStandard, RgbSpace} ;
19
19
//! # use palette::convert::FromColorUnclamped;
20
20
//! # use palette::{Xyz, Component, FloatComponent};
21
21
//! #
22
22
//! #[palette(
23
23
//! component = "T",
24
- //! rgb_space = "S",
25
- //! white_point = "S ::WhitePoint",
24
+ //! rgb_standard = "S",
25
+ //! white_point = "<S::Space as RgbSpace> ::WhitePoint",
26
26
//! )]
27
27
//! #[derive(FromColorUnclamped)]
28
28
//! #[repr(C)]
29
- //! struct ExampleType<S: RgbSpace , T: Component> {
29
+ //! struct ExampleType<S: RgbStandard , T: Component> {
30
30
//! // ...
31
31
//! #[palette(alpha)]
32
32
//! alpha: T,
33
- //! space : std::marker::PhantomData<S>,
33
+ //! standard : std::marker::PhantomData<S>,
34
34
//! }
35
35
//!
36
- //! # impl<S: RgbSpace, T: FloatComponent> FromColorUnclamped<Xyz<S::WhitePoint, T>> for ExampleType<S, T> {
37
- //! # fn from_color_unclamped(color: Xyz<S::WhitePoint, T>) -> Self {
38
- //! # ExampleType {alpha: T::max_intensity(), space: std::marker::PhantomData}
36
+ //! # impl<S, T> FromColorUnclamped<Xyz<<S::Space as RgbSpace>::WhitePoint, T>> for ExampleType<S, T>
37
+ //! # where
38
+ //! # S: RgbStandard,
39
+ //! # T: FloatComponent
40
+ //! # {
41
+ //! # fn from_color_unclamped(color: Xyz<<S::Space as RgbSpace>::WhitePoint, T>) -> Self {
42
+ //! # ExampleType {alpha: T::max_intensity(), standard: std::marker::PhantomData}
39
43
//! # }
40
44
//! # }
41
45
//! #
42
- //! # impl<S: RgbSpace, T: FloatComponent> FromColorUnclamped<ExampleType<S, T>> for Xyz<S::WhitePoint, T> {
46
+ //! # impl<S, T> FromColorUnclamped<ExampleType<S, T>> for Xyz<<S::Space as RgbSpace>::WhitePoint, T>
47
+ //! # where
48
+ //! # S: RgbStandard,
49
+ //! # T: FloatComponent
50
+ //! # {
43
51
//! # fn from_color_unclamped(color: ExampleType<S, T>) -> Self {
44
52
//! # Xyz::default()
45
53
//! # }
60
68
//! component type that should be used when deriving. The default is `f32`, but
61
69
//! it may be any other type, including type parameters.
62
70
//!
63
- //! * `rgb_space = "some::rgb_space ::Type"`: Sets the RGB space
71
+ //! * `rgb_standard = "some::rgb_standard ::Type"`: Sets the RGB standard
64
72
//! type that should be used when deriving. The default is to either use `Srgb`
65
- //! or a best effort to convert between spaces, so sometimes it has to be set
73
+ //! or a best effort to convert between standards, but sometimes it has to be set
66
74
//! to a specific type. This also accepts type parameters.
67
75
//!
68
76
//! ## Field Attributes
138
146
//! #[palette(
139
147
//! skip_derives(Rgb),
140
148
//! component = "T",
141
- //! rgb_space = "palette::encoding::Srgb"
149
+ //! rgb_standard = "palette::encoding::Srgb"
142
150
//! )]
143
151
//! #[derive(Copy, Clone, Pixel, FromColorUnclamped)]
144
152
//! #[repr(C)] // Makes sure the memory layout is as we want it.
185
193
//! 0.0,
186
194
//! 0.0,
187
195
//! 0.0,
188
- //! 0.7353569830524495 ,
189
- //! 0.5370987304831942 ,
196
+ //! 0.5 ,
197
+ //! 0.25 ,
190
198
//! ];
191
199
//! let hsv: Hsv<_, f64> = Bgr::from_raw_slice(&buffer)[1].into_color();
192
200
//!
209
217
//! /// CSS style sRGB.
210
218
//! #[palette(
211
219
//! skip_derives(Rgb),
212
- //! rgb_space = "palette::encoding::Srgb"
220
+ //! rgb_standard = "palette::encoding::Srgb"
213
221
//! )]
214
222
//! #[derive(PartialEq, Debug, FromColorUnclamped, WithAlpha)]
215
223
//! struct CssRgb {
@@ -528,7 +536,7 @@ mod tests {
528
536
skip_derives( Xyz , Luma ) ,
529
537
white_point = "S::WhitePoint" ,
530
538
component = "f64" ,
531
- rgb_space = "S " ,
539
+ rgb_standard = "Linear<S> " ,
532
540
palette_internal,
533
541
palette_internal_not_base_type
534
542
) ]
@@ -597,7 +605,7 @@ mod tests {
597
605
skip_derives( Lch , Luma ) ,
598
606
white_point = "crate::white_point::E" ,
599
607
component = "T" ,
600
- rgb_space = "(crate::encoding::Srgb, crate::white_point::E)" ,
608
+ rgb_standard = "Linear< (crate::encoding::Srgb, crate::white_point::E)> " ,
601
609
palette_internal,
602
610
palette_internal_not_base_type
603
611
) ]
@@ -667,7 +675,7 @@ mod tests {
667
675
let lch: Lch < _ , f64 > = Default :: default ( ) ;
668
676
WithXyz :: < crate :: encoding:: Srgb > :: from_color ( lch) ;
669
677
670
- let rgb: Rgb < crate :: encoding :: Srgb , f64 > = Default :: default ( ) ;
678
+ let rgb: Rgb < _ , f64 > = Default :: default ( ) ;
671
679
WithXyz :: < crate :: encoding:: Srgb > :: from_color ( rgb) ;
672
680
673
681
let hsl: Hsl < _ , f64 > = Default :: default ( ) ;
@@ -701,8 +709,7 @@ mod tests {
701
709
let lch: Alpha < Lch < _ , f64 > , u8 > = Alpha :: from ( Lch :: default ( ) ) ;
702
710
WithXyz :: < crate :: encoding:: Srgb > :: from_color ( lch) ;
703
711
704
- let rgb: Alpha < Rgb < crate :: encoding:: Srgb , f64 > , u8 > =
705
- Alpha :: from ( Rgb :: < crate :: encoding:: Srgb , f64 > :: default ( ) ) ;
712
+ let rgb: Alpha < Rgb < _ , f64 > , u8 > = Alpha :: from ( Rgb :: default ( ) ) ;
706
713
WithXyz :: < crate :: encoding:: Srgb > :: from_color ( rgb) ;
707
714
708
715
let hsl: Alpha < Hsl < _ , f64 > , u8 > = Alpha :: from ( Hsl :: default ( ) ) ;
@@ -736,7 +743,7 @@ mod tests {
736
743
let lch: Lch < _ , f64 > = Default :: default ( ) ;
737
744
Alpha :: < WithXyz < crate :: encoding:: Srgb > , u8 > :: from_color ( lch) ;
738
745
739
- let rgb: Rgb < crate :: encoding :: Srgb , f64 > = Default :: default ( ) ;
746
+ let rgb: Rgb < _ , f64 > = Default :: default ( ) ;
740
747
Alpha :: < WithXyz < crate :: encoding:: Srgb > , u8 > :: from_color ( rgb) ;
741
748
742
749
let hsl: Hsl < _ , f64 > = Default :: default ( ) ;
@@ -770,7 +777,7 @@ mod tests {
770
777
let lch: Lch < _ , f64 > = Default :: default ( ) ;
771
778
Alpha :: < WithXyz < crate :: encoding:: Srgb > , u8 > :: from_color ( lch) ;
772
779
773
- let rgb: Rgb < crate :: encoding :: Srgb , f64 > = Default :: default ( ) ;
780
+ let rgb: Rgb < _ , f64 > = Default :: default ( ) ;
774
781
Alpha :: < WithXyz < crate :: encoding:: Srgb > , u8 > :: from_color ( rgb) ;
775
782
776
783
let hsl: Hsl < _ , f64 > = Default :: default ( ) ;
@@ -795,7 +802,7 @@ mod tests {
795
802
let _yxy: Yxy < _ , f64 > = color. into_color ( ) ;
796
803
let _lab: Lab < _ , f64 > = color. into_color ( ) ;
797
804
let _lch: Lch < _ , f64 > = color. into_color ( ) ;
798
- let _rgb: Rgb < crate :: encoding :: Srgb , f64 > = color. into_color ( ) ;
805
+ let _rgb: Rgb < _ , f64 > = color. into_color ( ) ;
799
806
let _hsl: Hsl < _ , f64 > = color. into_color ( ) ;
800
807
let _hsv: Hsv < _ , f64 > = color. into_color ( ) ;
801
808
let _hwb: Hwb < _ , f64 > = color. into_color ( ) ;
@@ -812,7 +819,7 @@ mod tests {
812
819
let _yxy: Yxy < _ , f64 > = color. into_color ( ) ;
813
820
let _lab: Lab < _ , f64 > = color. into_color ( ) ;
814
821
let _lch: Lch < _ , f64 > = color. into_color ( ) ;
815
- let _rgb: Rgb < crate :: encoding :: Srgb , f64 > = color. into_color ( ) ;
822
+ let _rgb: Rgb < _ , f64 > = color. into_color ( ) ;
816
823
let _hsl: Hsl < _ , f64 > = color. into_color ( ) ;
817
824
let _hsv: Hsv < _ , f64 > = color. into_color ( ) ;
818
825
let _hwb: Hwb < _ , f64 > = color. into_color ( ) ;
@@ -828,7 +835,7 @@ mod tests {
828
835
let _yxy: Alpha < Yxy < _ , f64 > , u8 > = color. into_color ( ) ;
829
836
let _lab: Alpha < Lab < _ , f64 > , u8 > = color. into_color ( ) ;
830
837
let _lch: Alpha < Lch < _ , f64 > , u8 > = color. into_color ( ) ;
831
- let _rgb: Alpha < Rgb < crate :: encoding :: Srgb , f64 > , u8 > = color. into_color ( ) ;
838
+ let _rgb: Alpha < Rgb < _ , f64 > , u8 > = color. into_color ( ) ;
832
839
let _hsl: Alpha < Hsl < _ , f64 > , u8 > = color. into_color ( ) ;
833
840
let _hsv: Alpha < Hsv < _ , f64 > , u8 > = color. into_color ( ) ;
834
841
let _hwb: Alpha < Hwb < _ , f64 > , u8 > = color. into_color ( ) ;
@@ -845,7 +852,7 @@ mod tests {
845
852
let _yxy: Alpha < Yxy < _ , f64 > , u8 > = color. into_color ( ) ;
846
853
let _lab: Alpha < Lab < _ , f64 > , u8 > = color. into_color ( ) ;
847
854
let _lch: Alpha < Lch < _ , f64 > , u8 > = color. into_color ( ) ;
848
- let _rgb: Alpha < Rgb < crate :: encoding :: Srgb , f64 > , u8 > = color. into_color ( ) ;
855
+ let _rgb: Alpha < Rgb < _ , f64 > , u8 > = color. into_color ( ) ;
849
856
let _hsl: Alpha < Hsl < _ , f64 > , u8 > = color. into_color ( ) ;
850
857
let _hsv: Alpha < Hsv < _ , f64 > , u8 > = color. into_color ( ) ;
851
858
let _hwb: Alpha < Hwb < _ , f64 > , u8 > = color. into_color ( ) ;
@@ -869,7 +876,7 @@ mod tests {
869
876
let lch: Lch < crate :: white_point:: E , f64 > = Default :: default ( ) ;
870
877
WithoutXyz :: < f64 > :: from_color ( lch) ;
871
878
872
- let rgb: Rgb < ( _ , crate :: encoding :: Srgb ) , f64 > = Default :: default ( ) ;
879
+ let rgb: Rgb < _ , f64 > = Default :: default ( ) ;
873
880
WithoutXyz :: < f64 > :: from_color ( rgb) ;
874
881
875
882
let hsl: Hsl < _ , f64 > = Default :: default ( ) ;
@@ -894,7 +901,7 @@ mod tests {
894
901
let _yxy: Yxy < crate :: white_point:: E , f64 > = color. into_color ( ) ;
895
902
let _lab: Lab < crate :: white_point:: E , f64 > = color. into_color ( ) ;
896
903
let _lch: Lch < crate :: white_point:: E , f64 > = color. into_color ( ) ;
897
- let _rgb: Rgb < ( _ , crate :: encoding :: Srgb ) , f64 > = color. into_color ( ) ;
904
+ let _rgb: Rgb < _ , f64 > = color. into_color ( ) ;
898
905
let _hsl: Hsl < _ , f64 > = color. into_color ( ) ;
899
906
let _hsv: Hsv < _ , f64 > = color. into_color ( ) ;
900
907
let _hwb: Hwb < _ , f64 > = color. into_color ( ) ;
0 commit comments