@@ -525,7 +525,7 @@ impl Color {
525
525
let [ red, green, blue] =
526
526
LchRepresentation :: lch_to_nonlinear_srgb ( * lightness, * chroma, * hue) ;
527
527
528
- Color :: Rgba {
528
+ Color :: RgbaLinear {
529
529
red : red. nonlinear_to_linear_srgb ( ) ,
530
530
green : green. nonlinear_to_linear_srgb ( ) ,
531
531
blue : blue. nonlinear_to_linear_srgb ( ) ,
@@ -1858,4 +1858,22 @@ mod tests {
1858
1858
1859
1859
assert_eq ! ( starting_color * transformation, mutated_color, ) ;
1860
1860
}
1861
+
1862
+ // regression test for https://github.com/bevyengine/bevy/pull/8040
1863
+ #[ test]
1864
+ fn convert_to_rgba_linear ( ) {
1865
+ let rgba = Color :: rgba ( 0. , 0. , 0. , 0. ) ;
1866
+ let rgba_l = Color :: rgba_linear ( 0. , 0. , 0. , 0. ) ;
1867
+ let hsla = Color :: hsla ( 0. , 0. , 0. , 0. ) ;
1868
+ let lcha = Color :: Lcha {
1869
+ lightness : 0.0 ,
1870
+ chroma : 0.0 ,
1871
+ hue : 0.0 ,
1872
+ alpha : 0.0 ,
1873
+ } ;
1874
+ assert_eq ! ( rgba_l, rgba_l. as_rgba_linear( ) ) ;
1875
+ let Color :: RgbaLinear { .. } = rgba. as_rgba_linear ( ) else { panic ! ( "from Rgba" ) } ;
1876
+ let Color :: RgbaLinear { .. } = hsla. as_rgba_linear ( ) else { panic ! ( "from Hsla" ) } ;
1877
+ let Color :: RgbaLinear { .. } = lcha. as_rgba_linear ( ) else { panic ! ( "from Lcha" ) } ;
1878
+ }
1861
1879
}
0 commit comments