@@ -152,7 +152,7 @@ pub trait Color {
152
152
fn darken ( self , amount : Ratio ) -> Self ;
153
153
154
154
/// Decreases the transparency (or increase the opacity) of `self`, making it more opaque.
155
- /// Has no effect on opaque (non- alpha) colors .
155
+ /// For opqaue colors, converts into the alpha equivalent of `self`, and then increases the opacity .
156
156
/// For more, see Less' [Color Operations](http://lesscss.org/functions/#color-operations-fadein).
157
157
///
158
158
/// # Examples
@@ -163,12 +163,12 @@ pub trait Color {
163
163
/// let cornflower_blue = rgb(100, 149, 237);
164
164
///
165
165
/// assert_eq!(tomato.fadein(percent(25)), rgba(255, 99, 71, 0.5));
166
- /// assert_eq!(cornflower_blue.fadein(percent(50 )), rgb (100, 149, 237));
166
+ /// assert_eq!(cornflower_blue.fadein(percent(75 )), rgba (100, 149, 237, 1.0 ));
167
167
/// ```
168
- fn fadein ( self , amount : Ratio ) -> Self ;
168
+ fn fadein ( self , amount : Ratio ) -> Self :: Alpha ;
169
169
170
170
/// Increases the transparency (or decrease the opacity) of `self`, making it less opaque.
171
- /// Has no effect on opaque (non- alpha) colors .
171
+ /// For opqaue colors, converts into the alpha equivalent of `self`, and then decreases the opacity .
172
172
/// For more, see Less' [Color Operations](http://lesscss.org/functions/#color-operations-fadeout).
173
173
///
174
174
/// # Examples
@@ -179,11 +179,11 @@ pub trait Color {
179
179
/// let cornflower_blue = rgb(100, 149, 237);
180
180
///
181
181
/// assert_eq!(tomato.fadeout(percent(25)), rgba(255, 99, 71, 0.25));
182
- /// assert_eq!(cornflower_blue.fadeout(percent(50 )), rgb (100, 149, 237));
182
+ /// assert_eq!(cornflower_blue.fadeout(percent(75 )), rgba (100, 149, 237, 0.25 ));
183
183
/// ```
184
- fn fadeout ( self , amount : Ratio ) -> Self ;
184
+ fn fadeout ( self , amount : Ratio ) -> Self :: Alpha ;
185
185
186
- /// Sets the absolute opacity of `self`.
186
+ /// Sets the absolute opacity of `self`, and returns the alpha equivalent .
187
187
/// Can be applied to colors whether they already have an opacity value or not.
188
188
/// For more, see Less' [Color Operations](http://lesscss.org/functions/#color-operations-fade).
189
189
///
@@ -633,12 +633,12 @@ mod css_color_tests {
633
633
634
634
#[ test]
635
635
fn can_fadein ( ) {
636
- assert_approximately_eq ! ( hsl( 9 , 35 , 50 ) . fadein( percent( 25 ) ) , hsl ( 9 , 35 , 50 ) ) ;
636
+ assert_approximately_eq ! ( hsl( 9 , 35 , 50 ) . fadein( percent( 25 ) ) , hsla ( 9 , 35 , 50 , 1.0 ) ) ;
637
637
assert_approximately_eq ! (
638
638
hsla( 9 , 35 , 50 , 0.5 ) . fadein( percent( 25 ) ) ,
639
639
hsla( 9 , 35 , 50 , 0.75 )
640
640
) ;
641
- assert_approximately_eq ! ( rgb( 172 , 96 , 83 ) . fadein( percent( 25 ) ) , rgb ( 172 , 96 , 83 ) ) ;
641
+ assert_approximately_eq ! ( rgb( 172 , 96 , 83 ) . fadein( percent( 25 ) ) , rgba ( 172 , 96 , 83 , 1.0 ) ) ;
642
642
assert_approximately_eq ! (
643
643
rgba( 172 , 96 , 83 , 0.50 ) . fadein( percent( 25 ) ) ,
644
644
rgba( 172 , 96 , 83 , 0.75 )
@@ -647,8 +647,11 @@ mod css_color_tests {
647
647
648
648
#[ test]
649
649
fn can_fadeout ( ) {
650
- assert_approximately_eq ! ( hsl( 9 , 35 , 50 ) . fadeout( percent( 25 ) ) , hsl( 9 , 35 , 50 ) ) ;
651
- assert_approximately_eq ! ( rgb( 172 , 96 , 83 ) . fadeout( percent( 25 ) ) , rgb( 172 , 96 , 83 ) ) ;
650
+ assert_approximately_eq ! ( hsl( 9 , 35 , 50 ) . fadeout( percent( 25 ) ) , hsla( 9 , 35 , 50 , 0.75 ) ) ;
651
+ assert_approximately_eq ! (
652
+ rgb( 172 , 96 , 83 ) . fadeout( percent( 25 ) ) ,
653
+ rgba( 172 , 96 , 83 , 0.75 )
654
+ ) ;
652
655
assert_approximately_eq ! (
653
656
hsla( 9 , 35 , 50 , 0.60 ) . fadeout( percent( 25 ) ) ,
654
657
hsla( 9 , 35 , 50 , 0.35 )
0 commit comments