@@ -34,7 +34,7 @@ fn serialize_alpha(dest: &mut impl fmt::Write, alpha: f32, legacy_syntax: bool)
34
34
/// A color with red, green, blue, and alpha components, in a byte each.
35
35
#[ derive( Clone , Copy , PartialEq , Debug ) ]
36
36
#[ repr( C ) ]
37
- pub struct RGBA {
37
+ pub struct Rgba {
38
38
/// The red component.
39
39
pub red : u8 ,
40
40
/// The green component.
@@ -45,7 +45,7 @@ pub struct RGBA {
45
45
pub alpha : f32 ,
46
46
}
47
47
48
- impl RGBA {
48
+ impl Rgba {
49
49
/// Constructs a new RGBA value from float components. It expects the red,
50
50
/// green, blue and alpha channels in that order, and all values will be
51
51
/// clamped to the 0.0 ... 1.0 range.
@@ -134,7 +134,7 @@ impl RGBA {
134
134
}
135
135
136
136
#[ cfg( feature = "serde" ) ]
137
- impl Serialize for RGBA {
137
+ impl Serialize for Rgba {
138
138
fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
139
139
where
140
140
S : Serializer ,
@@ -144,17 +144,17 @@ impl Serialize for RGBA {
144
144
}
145
145
146
146
#[ cfg( feature = "serde" ) ]
147
- impl < ' de > Deserialize < ' de > for RGBA {
147
+ impl < ' de > Deserialize < ' de > for Rgba {
148
148
fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
149
149
where
150
150
D : Deserializer < ' de > ,
151
151
{
152
152
let ( r, g, b, a) = Deserialize :: deserialize ( deserializer) ?;
153
- Ok ( RGBA :: new ( r, g, b, a) )
153
+ Ok ( Rgba :: new ( r, g, b, a) )
154
154
}
155
155
}
156
156
157
- impl ToCss for RGBA {
157
+ impl ToCss for Rgba {
158
158
fn to_css < W > ( & self , dest : & mut W ) -> fmt:: Result
159
159
where
160
160
W : fmt:: Write ,
@@ -180,7 +180,7 @@ impl ToCss for RGBA {
180
180
/// Color specified by lightness, a- and b-axis components.
181
181
#[ derive( Clone , Copy , PartialEq , Debug ) ]
182
182
#[ repr( C ) ]
183
- pub struct LAB {
183
+ pub struct Lab {
184
184
/// The lightness component.
185
185
pub lightness : f32 ,
186
186
/// The a-axis component.
@@ -194,7 +194,7 @@ pub struct LAB {
194
194
/// Color specified by lightness, a- and b-axis components.
195
195
#[ derive( Clone , Copy , PartialEq , Debug ) ]
196
196
#[ repr( C ) ]
197
- pub struct OKLAB {
197
+ pub struct Oklab {
198
198
/// The lightness component.
199
199
pub lightness : f32 ,
200
200
/// The a-axis component.
@@ -259,16 +259,16 @@ macro_rules! impl_lab_like {
259
259
} ;
260
260
}
261
261
262
- impl_lab_like ! ( LAB , "lab" ) ;
263
- impl_lab_like ! ( OKLAB , "oklab" ) ;
262
+ impl_lab_like ! ( Lab , "lab" ) ;
263
+ impl_lab_like ! ( Oklab , "oklab" ) ;
264
264
265
265
// NOTE: LCH and OKLCH is not declared inside the [impl_lch_like] macro,
266
266
// because it causes cbindgen to ignore them.
267
267
268
268
/// Color specified by lightness, chroma and hue components.
269
269
#[ derive( Clone , Copy , PartialEq , Debug ) ]
270
270
#[ repr( C ) ]
271
- pub struct LCH {
271
+ pub struct Lch {
272
272
/// The lightness component.
273
273
pub lightness : f32 ,
274
274
/// The chroma component.
@@ -282,7 +282,7 @@ pub struct LCH {
282
282
/// Color specified by lightness, chroma and hue components.
283
283
#[ derive( Clone , Copy , PartialEq , Debug ) ]
284
284
#[ repr( C ) ]
285
- pub struct OKLCH {
285
+ pub struct Oklch {
286
286
/// The lightness component.
287
287
pub lightness : f32 ,
288
288
/// The chroma component.
@@ -347,29 +347,29 @@ macro_rules! impl_lch_like {
347
347
} ;
348
348
}
349
349
350
- impl_lch_like ! ( LCH , "lch" ) ;
351
- impl_lch_like ! ( OKLCH , "oklch" ) ;
350
+ impl_lch_like ! ( Lch , "lch" ) ;
351
+ impl_lch_like ! ( Oklch , "oklch" ) ;
352
352
353
353
/// An absolutely specified color.
354
354
/// https://w3c.github.io/csswg-drafts/css-color-4/#typedef-absolute-color-base
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 {
@@ -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.
@@ -565,7 +565,7 @@ impl Color {
565
565
let location = input. current_source_location ( ) ;
566
566
let token = input. next ( ) ?;
567
567
match * token {
568
- Token :: Hash ( ref value) | Token :: IDHash ( ref value) => RGBA :: parse_hash ( value. as_bytes ( ) )
568
+ Token :: Hash ( ref value) | Token :: IDHash ( ref value) => Rgba :: parse_hash ( value. as_bytes ( ) )
569
569
. map ( |rgba| Color :: Absolute ( AbsoluteColor :: RGBA ( rgba) ) ) ,
570
570
Token :: Ident ( ref value) => parse_color_keyword ( & * value) ,
571
571
Token :: Function ( ref name) => {
@@ -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