// id to rgb color pub fn id_to_color(id: u64) -> [u8; 3] { let mut hash = id; hash ^= hash >> 16; hash = hash.wrapping_mul(0x85ebca6b); hash ^= hash >> 13; hash = hash.wrapping_mul(0xb00b1355); hash ^= hash >> 16; let hue = (hash % 360) as f32; let saturation = 0.7 + ((hash >> 8) % 30) as f32 / 100.0; // 0.7-1.0 for vibrant colors let value = 0.6 + ((hash >> 16) % 40) as f32 / 100.0; // 0.6-1.0 to avoid dark colors hsv_to_rgb(hue, saturation, value) } fn hsv_to_rgb(h: f32, s: f32, v: f32) -> [u8; 3] { let c = v * s; let x = c * (1.0 - ((h / 60.0) % 2.0 - 1.0).abs()); let m = v - c; let (r_prime, g_prime, b_prime) = if h < 60.0 { (c, x, 0.0) } else if h < 120.0 { (x, c, 0.0) } else if h < 180.0 { (0.0, c, x) } else if h < 240.0 { (0.0, x, c) } else if h < 300.0 { (x, 0.0, c) } else { (c, 0.0, x) }; [ ((r_prime + m) * 255.0) as u8, ((g_prime + m) * 255.0) as u8, ((b_prime + m) * 255.0) as u8, ] }