@@ -355,32 +355,32 @@ impl_lch_like!(Oklch, "oklch");
355
355
#[ derive( Clone , Copy , PartialEq , Debug ) ]
356
356
pub enum AbsoluteColor {
357
357
/// Specify sRGB colors directly by their red/green/blue/alpha chanels.
358
- RGBA ( Rgba ) ,
358
+ Rgba ( Rgba ) ,
359
359
/// Specifies a CIELAB color by CIE Lightness and its a- and b-axis hue
360
360
/// coordinates (red/green-ness, and yellow/blue-ness) using the CIE LAB
361
361
/// rectangular coordinate model.
362
- LAB ( Lab ) ,
362
+ Lab ( Lab ) ,
363
363
/// Specifies a CIELAB color by CIE Lightness, Chroma, and hue using the
364
364
/// CIE LCH cylindrical coordinate model.
365
- LCH ( Lch ) ,
365
+ Lch ( Lch ) ,
366
366
/// Specifies an Oklab color by Oklab Lightness and its a- and b-axis hue
367
367
/// coordinates (red/green-ness, and yellow/blue-ness) using the Oklab
368
368
/// rectangular coordinate model.
369
- OKLAB ( Oklab ) ,
369
+ Oklab ( Oklab ) ,
370
370
/// Specifies an Oklab color by Oklab Lightness, Chroma, and hue using
371
371
/// the OKLCH cylindrical coordinate model.
372
- OKLCH ( Oklch ) ,
372
+ Oklch ( Oklch ) ,
373
373
}
374
374
375
375
impl AbsoluteColor {
376
376
/// Return the alpha component of any of the schemes within.
377
377
pub fn alpha ( & self ) -> f32 {
378
378
match self {
379
- Self :: RGBA ( c) => c. alpha ,
380
- Self :: LAB ( c) => c. alpha ,
381
- Self :: LCH ( c) => c. alpha ,
382
- Self :: OKLAB ( c) => c. alpha ,
383
- Self :: OKLCH ( c) => c. alpha ,
379
+ Self :: Rgba ( c) => c. alpha ,
380
+ Self :: Lab ( c) => c. alpha ,
381
+ Self :: Lch ( c) => c. alpha ,
382
+ Self :: Oklab ( c) => c. alpha ,
383
+ Self :: Oklch ( c) => c. alpha ,
384
384
}
385
385
}
386
386
}
@@ -391,11 +391,11 @@ impl ToCss for AbsoluteColor {
391
391
W : fmt:: Write ,
392
392
{
393
393
match self {
394
- Self :: RGBA ( rgba) => rgba. to_css ( dest) ,
395
- Self :: LAB ( lab) => lab. to_css ( dest) ,
396
- Self :: LCH ( lch) => lch. to_css ( dest) ,
397
- Self :: OKLAB ( lab) => lab. to_css ( dest) ,
398
- Self :: OKLCH ( lch) => lch. to_css ( dest) ,
394
+ Self :: Rgba ( rgba) => rgba. to_css ( dest) ,
395
+ Self :: Lab ( lab) => lab. to_css ( dest) ,
396
+ Self :: Lch ( lch) => lch. to_css ( dest) ,
397
+ Self :: Oklab ( lab) => lab. to_css ( dest) ,
398
+ Self :: Oklch ( lch) => lch. to_css ( dest) ,
399
399
}
400
400
}
401
401
}
@@ -407,7 +407,7 @@ pub(crate) const fn rgb(red: u8, green: u8, blue: u8) -> Color {
407
407
408
408
#[ inline]
409
409
pub ( crate ) const fn rgba ( red : u8 , green : u8 , blue : u8 , alpha : f32 ) -> Color {
410
- Color :: Absolute ( AbsoluteColor :: RGBA ( Rgba :: new ( red, green, blue, alpha) ) )
410
+ Color :: Absolute ( AbsoluteColor :: Rgba ( Rgba :: new ( red, green, blue, alpha) ) )
411
411
}
412
412
413
413
/// A <color> value.
@@ -566,7 +566,7 @@ impl Color {
566
566
let token = input. next ( ) ?;
567
567
match * token {
568
568
Token :: Hash ( ref value) | Token :: IDHash ( ref value) => Rgba :: parse_hash ( value. as_bytes ( ) )
569
- . map ( |rgba| Color :: Absolute ( AbsoluteColor :: RGBA ( rgba) ) ) ,
569
+ . map ( |rgba| Color :: Absolute ( AbsoluteColor :: Rgba ( rgba) ) ) ,
570
570
Token :: Ident ( ref value) => parse_color_keyword ( & * value) ,
571
571
Token :: Function ( ref name) => {
572
572
let name = name. clone ( ) ;
@@ -806,25 +806,25 @@ where
806
806
// for L: 0% = 0.0, 100% = 100.0
807
807
// for a and b: -100% = -125, 100% = 125
808
808
"lab" => parse_lab_like( component_parser, arguments, 100.0 , 125.0 , |l, a, b, alpha| {
809
- Color :: Absolute ( AbsoluteColor :: LAB ( Lab :: new( l. max( 0. ) , a , b , alpha) ) )
809
+ Color :: Absolute ( AbsoluteColor :: Lab ( Lab :: new( l. max( 0. ) , a , b , alpha) ) )
810
810
} ) ,
811
811
812
812
// for L: 0% = 0.0, 100% = 100.0
813
813
// for C: 0% = 0, 100% = 150
814
814
"lch" => parse_lch_like( component_parser, arguments, 100.0 , 150.0 , |l, c, h, alpha| {
815
- Color :: Absolute ( AbsoluteColor :: LCH ( Lch :: new( l. max( 0. ) , c. max( 0. ) , h, alpha) ) )
815
+ Color :: Absolute ( AbsoluteColor :: Lch ( Lch :: new( l. max( 0. ) , c. max( 0. ) , h, alpha) ) )
816
816
} ) ,
817
817
818
818
// for L: 0% = 0.0, 100% = 1.0
819
819
// for a and b: -100% = -0.4, 100% = 0.4
820
820
"oklab" => parse_lab_like( component_parser, arguments, 1.0 , 0.4 , |l, a, b, alpha| {
821
- Color :: Absolute ( AbsoluteColor :: OKLAB ( Oklab :: new( l. max( 0. ) , a, b, alpha) ) )
821
+ Color :: Absolute ( AbsoluteColor :: Oklab ( Oklab :: new( l. max( 0. ) , a, b, alpha) ) )
822
822
} ) ,
823
823
824
824
// for L: 0% = 0.0, 100% = 1.0
825
825
// for C: 0% = 0.0 100% = 0.4
826
826
"oklch" => parse_lch_like( component_parser, arguments, 1.0 , 0.4 , |l, c, h, alpha| {
827
- Color :: Absolute ( AbsoluteColor :: OKLCH ( Oklch :: new( l. max( 0. ) , c. max( 0. ) , h, alpha) ) )
827
+ Color :: Absolute ( AbsoluteColor :: Oklch ( Oklch :: new( l. max( 0. ) , c. max( 0. ) , h, alpha) ) )
828
828
} ) ,
829
829
830
830
_ => return Err ( arguments. new_unexpected_token_error( Token :: Ident ( name. to_owned( ) . into( ) ) ) ) ,
0 commit comments