use crate::ir::{Color, Theme};
const fn rgb(r: u8, g: u8, b: u8) -> Color {
Color { r, g, b, a: 1.0 }
}
pub static PALETTE: &[Color] = &[
rgb(54, 162, 235), rgb(255, 99, 132), rgb(255, 159, 64), rgb(255, 205, 86), rgb(75, 192, 192), rgb(153, 102, 255), rgb(201, 203, 207), ];
pub fn palette_color(i: usize) -> Color {
PALETTE[i % PALETTE.len()]
}
pub static VEGALITE_PALETTE: &[Color] = &[
rgb(76, 120, 168), rgb(245, 133, 24), rgb(228, 87, 86), rgb(114, 183, 178), rgb(84, 162, 75), rgb(238, 202, 59), rgb(178, 121, 162), rgb(255, 157, 166), rgb(157, 117, 93), rgb(186, 176, 172), ];
pub fn vegalite_theme() -> Theme {
Theme {
palette: VEGALITE_PALETTE.to_vec(),
is_custom_palette: false,
grid_color: rgb(221, 221, 221), text_color: rgb(51, 51, 51), background: Some(rgb(255, 255, 255)),
font_size: 11.0,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn cycles_through_palette() {
let n = PALETTE.len();
assert!(n >= 6);
assert_eq!(palette_color(0), palette_color(n));
assert_eq!(palette_color(1), palette_color(n + 1));
}
#[test]
fn first_color_is_chartjs_blue() {
let c = palette_color(0);
assert_eq!((c.r, c.g, c.b), (54, 162, 235)); }
}