diff --git a/src/styles/palette.rs b/src/styles/palette.rs index 1ea9fd1..e7a4db6 100644 --- a/src/styles/palette.rs +++ b/src/styles/palette.rs @@ -1,13 +1,28 @@ +/// A module for creating palette color. +/// +/// This module provides an struct `PaletteColor` +/// that represents palette color, index should be between 0 to 255 mean u8. +/// It also implements the `Stylify` trait for `PaletteColor`, +/// which allows for generating styles based on the paint type. + +// ======================================================================= + use super::{ paint_type::PaintType, Stylify }; // ======================================================================= +/// An struct representing index of palette color. +/// +/// This struct has 1 field: `index`, which represent 8 bit color code between 0 to 255. #[derive(Debug, Clone)] pub struct PaletteColor { pub index: u8, } impl Stylify for PaletteColor { + /// Returns a string representation of the palette index code. + /// + /// If `paint_type` is `None`, the foreground color is assumed. fn make_styles(&self, paint_type: Option<&PaintType>) -> String { let paint_type = paint_type.unwrap_or(&PaintType::FG); format!(