graphic design tool
git clone https://git.lucas.co/cce-designer.git
refactor: use cce_ui::color hex parser instead of a local copy
Delegate the local hex-color parse to cce_ui::color::parse_hex_* (single source
of truth), preserving the function signature and gamma handling.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
src/app.rs | 10 +---------
src/project.rs | 10 +---------
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/src/app.rs b/src/app.rs
index 1ef47ca..cb62682 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -406,15 +406,7 @@ fn float_array_to_hex(rgb: &[f32; 3]) -> String {
}
fn hex_to_float_array(hex: &str) -> Option<[f32; 3]> {
- let s = hex.trim_start_matches('#');
- if s.len() == 6 {
- let r = u8::from_str_radix(&s[0..2], 16).ok()? as f32 / 255.0;
- let g = u8::from_str_radix(&s[2..4], 16).ok()? as f32 / 255.0;
- let b = u8::from_str_radix(&s[4..6], 16).ok()? as f32 / 255.0;
- Some([r, g, b])
- } else {
- None
- }
+ cce_ui::color::parse_hex_rgb(hex)
}
impl DesignSettings {
diff --git a/src/project.rs b/src/project.rs
index 8c41032..70c044d 100644
--- a/src/project.rs
+++ b/src/project.rs
@@ -13,15 +13,7 @@ fn color_to_hex(rgb: [f32; 3]) -> String {
}
fn hex_to_color(hex: &str) -> Option<[f32; 3]> {
- let s = hex.trim().strip_prefix('#').unwrap_or(hex.trim());
- if s.len() == 6 {
- let r = u8::from_str_radix(&s[0..2], 16).ok()? as f32 / 255.0;
- let g = u8::from_str_radix(&s[2..4], 16).ok()? as f32 / 255.0;
- let b = u8::from_str_radix(&s[4..6], 16).ok()? as f32 / 255.0;
- Some([r, g, b])
- } else {
- None
- }
+ cce_ui::color::parse_hex_rgb(hex)
}
impl State {