@@ -253,6 +253,43 @@ impl Color {
253
253
}
254
254
}
255
255
256
+ /// New `Color` with LCH representation in sRGB colorspace.
257
+ ///
258
+ /// # Arguments
259
+ ///
260
+ /// * `lightness` - Lightness channel. [0.0, 1.5]
261
+ /// * `chroma` - Chroma channel. [0.0, 1.5]
262
+ /// * `hue` - Hue channel. [0.0, 360.0]
263
+ ///
264
+ /// See also [`Color::lcha`].
265
+ pub const fn lch ( lightness : f32 , chroma : f32 , hue : f32 ) -> Color {
266
+ Color :: Lcha {
267
+ lightness,
268
+ chroma,
269
+ hue,
270
+ alpha : 1.0 ,
271
+ }
272
+ }
273
+
274
+ /// New `Color` with LCH representation in sRGB colorspace.
275
+ ///
276
+ /// # Arguments
277
+ ///
278
+ /// * `lightness` - Lightness channel. [0.0, 1.5]
279
+ /// * `chroma` - Chroma channel. [0.0, 1.5]
280
+ /// * `hue` - Hue channel. [0.0, 360.0]
281
+ /// * `alpha` - Alpha channel. [0.0, 1.0]
282
+ ///
283
+ /// See also [`Color::lch`].
284
+ pub const fn lcha ( lightness : f32 , chroma : f32 , hue : f32 , alpha : f32 ) -> Color {
285
+ Color :: Lcha {
286
+ lightness,
287
+ chroma,
288
+ hue,
289
+ alpha,
290
+ }
291
+ }
292
+
256
293
/// New `Color` from sRGB colorspace.
257
294
///
258
295
/// # Examples
@@ -1865,12 +1902,7 @@ mod tests {
1865
1902
let rgba = Color :: rgba ( 0. , 0. , 0. , 0. ) ;
1866
1903
let rgba_l = Color :: rgba_linear ( 0. , 0. , 0. , 0. ) ;
1867
1904
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
- } ;
1905
+ let lcha = Color :: lcha ( 0. , 0. , 0. , 0. ) ;
1874
1906
assert_eq ! ( rgba_l, rgba_l. as_rgba_linear( ) ) ;
1875
1907
let Color :: RgbaLinear { .. } = rgba. as_rgba_linear ( ) else { panic ! ( "from Rgba" ) } ;
1876
1908
let Color :: RgbaLinear { .. } = hsla. as_rgba_linear ( ) else { panic ! ( "from Hsla" ) } ;
0 commit comments