Skip to main content

dear_implot/
colormap.rs

1use crate::{ColormapIndex, sys};
2
3/// Built-in colormaps
4#[repr(i32)]
5#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6pub enum Colormap {
7    Deep = sys::ImPlotColormap_Deep as i32,
8    Dark = sys::ImPlotColormap_Dark as i32,
9    Pastel = sys::ImPlotColormap_Pastel as i32,
10    Paired = sys::ImPlotColormap_Paired as i32,
11    Viridis = sys::ImPlotColormap_Viridis as i32,
12    Plasma = sys::ImPlotColormap_Plasma as i32,
13    Hot = sys::ImPlotColormap_Hot as i32,
14    Cool = sys::ImPlotColormap_Cool as i32,
15    Pink = sys::ImPlotColormap_Pink as i32,
16    Jet = sys::ImPlotColormap_Jet as i32,
17    Twilight = sys::ImPlotColormap_Twilight as i32,
18    RdBu = sys::ImPlotColormap_RdBu as i32,
19    BrBG = sys::ImPlotColormap_BrBG as i32,
20    PiYG = sys::ImPlotColormap_PiYG as i32,
21    Spectral = sys::ImPlotColormap_Spectral as i32,
22    Greys = sys::ImPlotColormap_Greys as i32,
23}
24
25impl Colormap {
26    #[inline]
27    pub const fn index(self) -> ColormapIndex {
28        match ColormapIndex::from_raw(self as i32) {
29            Some(index) => index,
30            None => panic!("built-in ImPlot colormap index must be valid"),
31        }
32    }
33}