summaryrefslogtreecommitdiff
path: root/crates/material_theme/src/utils.rs
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2025-04-17 03:00:52 +0200
committerpml68 <contact@pml68.dev>2025-04-17 03:06:43 +0200
commitce62ff16fbd8e839b5f707f8d9637db083945803 (patch)
tree8d7651817fbf17b24f4baae9cc72c83fd224ca71 /crates/material_theme/src/utils.rs
parentfeat(material_theme): implement `radio::Catalog` (diff)
downloadiced-builder-ce62ff16fbd8e839b5f707f8d9637db083945803.tar.gz
refactor: inline Dark and Light theme definitions, remove toml files
Diffstat (limited to 'crates/material_theme/src/utils.rs')
-rw-r--r--crates/material_theme/src/utils.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/material_theme/src/utils.rs b/crates/material_theme/src/utils.rs
index a05bc62..f35396f 100644
--- a/crates/material_theme/src/utils.rs
+++ b/crates/material_theme/src/utils.rs
@@ -66,6 +66,26 @@ pub fn parse_argb(s: &str) -> Option<Color> {
})
}
+pub fn color_to_argb(color: Color) -> String {
+ use std::fmt::Write;
+
+ let mut hex = String::with_capacity(9);
+
+ let [r, g, b, a] = color.into_rgba8();
+
+ let _ = write!(&mut hex, "#");
+
+ if a < u8::MAX {
+ let _ = write!(&mut hex, "{a:02X}");
+ }
+
+ let _ = write!(&mut hex, "{r:02X}");
+ let _ = write!(&mut hex, "{g:02X}");
+ let _ = write!(&mut hex, "{b:02X}");
+
+ hex
+}
+
pub fn mix(color1: Color, color2: Color, p2: f32) -> Color {
if p2 <= 0.0 {
return color1;