From ddb38cc3a31e47c86e9f2b1864799c4575a15231 Mon Sep 17 00:00:00 2001 From: InioX Date: Mon, 11 Dec 2023 19:52:54 +0100 Subject: [PATCH] feat: add new formats for keywords --- src/util/template.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/util/template.rs b/src/util/template.rs index 15cc524..9597ef4 100644 --- a/src/util/template.rs +++ b/src/util/template.rs @@ -44,6 +44,13 @@ struct Colora { rgba: String, hsl: String, hsla: String, + red: String, + green: String, + blue: String, + alpha: String, + hue: String, + saturation: String, + lightness: String, } #[derive(Serialize, Deserialize, Debug)] @@ -391,5 +398,48 @@ fn generate_color_strings(color: Color) -> Colora { None, ) .to_css_string(), + red: format!( + "{:?}", + color.blue + ), + green: format!( + "{:?}", + color.green + ), + blue: format!( + "{:?}", + color.blue + ), + alpha: format!( + "{:?}", + color.alpha + ), + hue: format!( + "{:?}", + Hsl::new( + color.red as f64, + color.green as f64, + color.blue as f64, + Some(color.alpha as f64), + ).hue() + ), + lightness: format!( + "{:?}", + Hsl::new( + color.red as f64, + color.green as f64, + color.blue as f64, + Some(color.alpha as f64), + ).lightness() + ), + saturation: format!( + "{:?}", + Hsl::new( + color.red as f64, + color.green as f64, + color.blue as f64, + Some(color.alpha as f64), + ).saturation() + ), } }