rat_theme2/palettes/
blackwhite.rs

1use crate::Palette;
2use ratatui::style::Color;
3
4///
5/// Almost genuine black&white color-palette.
6///
7/// It uses black, white and bright as the standard colors.
8/// To match the Palette semantics I needed two gray-scales
9/// to make it work like the other color-palettes.
10///
11pub const BLACKWHITE: Palette = Palette {
12    primary: interpolate(0xffffff, 0xffffff, 0xaaaaaa, 0xaaaaaa),
13    secondary: interpolate(0x000000, 0x000000, 0x000000, 0x000000),
14
15    white: interpolate(0xffffff, 0xffffff, 0xaaaaaa, 0xaaaaaa),
16    black: interpolate(0x000000, 0x000000, 0x000000, 0x000000),
17    gray: interpolate(0x808080, 0x808080, 0x555555, 0x555555),
18
19    red: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
20    orange: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
21    yellow: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
22    limegreen: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
23    green: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
24    bluegreen: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
25    cyan: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
26    blue: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
27    deepblue: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
28    purple: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
29    magenta: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
30    redpink: interpolate(0xffffff, 0xaaaaaa, 0x000000, 0x555555),
31};
32
33/// Calculates a linear interpolation for the two colors
34/// and fills the first 4 colors.
35///
36///
37const fn interpolate(c0: u32, c1: u32, c2: u32, c3: u32) -> [Color; 8] {
38    let r0 = (c0 >> 16) as u8;
39    let g0 = (c0 >> 8) as u8;
40    let b0 = c0 as u8;
41
42    let r2 = (c1 >> 16) as u8;
43    let g2 = (c1 >> 8) as u8;
44    let b2 = c1 as u8;
45
46    let r4 = (c2 >> 16) as u8;
47    let g4 = (c2 >> 8) as u8;
48    let b4 = c2 as u8;
49
50    let r6 = (c3 >> 16) as u8;
51    let g6 = (c3 >> 8) as u8;
52    let b6 = c3 as u8;
53
54    [
55        Color::Rgb(r0, g0, b0),
56        Color::Rgb(r0, g0, b0),
57        Color::Rgb(r2, g2, b2),
58        Color::Rgb(r2, g2, b2),
59        Color::Rgb(r4, g4, b4),
60        Color::Rgb(r4, g4, b4),
61        Color::Rgb(r6, g6, b6),
62        Color::Rgb(r6, g6, b6),
63    ]
64}