File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// A module for creating palette color.
2
+ ///
3
+ /// This module provides an struct `PaletteColor`
4
+ /// that represents palette color, index should be between 0 to 255 mean u8.
5
+ /// It also implements the `Stylify` trait for `PaletteColor`,
6
+ /// which allows for generating styles based on the paint type.
7
+
8
+ // =======================================================================
9
+
1
10
use super :: { paint_type:: PaintType , Stylify } ;
2
11
3
12
// =======================================================================
4
13
14
+ /// An struct representing index of palette color.
15
+ ///
16
+ /// This struct has 1 field: `index`, which represent 8 bit color code between 0 to 255.
5
17
#[ derive( Debug , Clone ) ]
6
18
pub struct PaletteColor {
7
19
pub index : u8 ,
8
20
}
9
21
10
22
impl Stylify for PaletteColor {
23
+ /// Returns a string representation of the palette index code.
24
+ ///
25
+ /// If `paint_type` is `None`, the foreground color is assumed.
11
26
fn make_styles ( & self , paint_type : Option < & PaintType > ) -> String {
12
27
let paint_type = paint_type. unwrap_or ( & PaintType :: FG ) ;
13
28
format ! (
You can’t perform that action at this time.
0 commit comments