1use blinc_core::Color;
8
9pub const BG: Color = Color::rgba(0.04, 0.04, 0.05, 1.0); pub const ACCENT: Color = Color::rgba(0.77, 0.58, 0.42, 1.0); pub const EDGE_COLOR: Color = Color::rgba(0.29, 0.29, 0.33, 1.0); pub const TEXT_COLOR: Color = Color::rgba(0.91, 0.90, 0.89, 1.0); pub const TEXT_DIM: Color = Color::rgba(0.53, 0.53, 0.53, 0.8); pub const BORDER: Color = Color::rgba(0.16, 0.16, 0.21, 1.0); pub const NODE_RADIUS: f32 = 16.0;
21
22pub const NODE_PALETTE: [Color; 8] = [
25 Color::rgba(0.77, 0.58, 0.42, 1.0), Color::rgba(0.40, 0.70, 0.90, 1.0), Color::rgba(0.60, 0.85, 0.55, 1.0), Color::rgba(0.85, 0.50, 0.55, 1.0), Color::rgba(0.70, 0.55, 0.85, 1.0), Color::rgba(0.90, 0.75, 0.40, 1.0), Color::rgba(0.45, 0.80, 0.75, 1.0), Color::rgba(0.85, 0.60, 0.75, 1.0), ];
34
35pub fn label_color(label: &str) -> Color {
37 let hash = label
38 .bytes()
39 .fold(0u32, |acc, b| acc.wrapping_mul(31).wrapping_add(b as u32));
40 NODE_PALETTE[(hash as usize) % NODE_PALETTE.len()]
41}
42
43pub fn label_color_idx(label: &str) -> u8 {
45 let hash = label
46 .bytes()
47 .fold(0u32, |acc, b| acc.wrapping_mul(31).wrapping_add(b as u32));
48 (hash as usize % NODE_PALETTE.len()) as u8
49}