//! Hex colors used by app forms, badges, and metadata swatches.
/// Parse exactly `#rrggbb`; callers decide whether to trim whitespace.
pub(crate) fn parse_hex_color(value: &str) -> Option<egui::Color32> {
let digits = value.strip_prefix('#')?;
if digits.len() != 6 || !digits.bytes().all(|byte| byte.is_ascii_hexdigit()) {
return None;
}
let rgb = u32::from_str_radix(digits, 16).ok()?;
Some(egui::Color32::from_rgb(
(rgb >> 16) as u8,
(rgb >> 8) as u8,
rgb as u8,
))
}
pub(crate) fn rgb_to_hex(rgb: [u8; 3]) -> String {
format!("#{:02x}{:02x}{:02x}", rgb[0], rgb[1], rgb[2])
}
// BREP private tests: 21fd460a280bf9c5