re_sdk_types/components/
colormap_ext.rs1use super::Colormap;
2use crate::ColormapCategory;
3
4impl Colormap {
5 pub fn from_u8(value: u8) -> Option<Self> {
9 match Self::default() {
12 Self::Grayscale
13 | Self::Inferno
14 | Self::Magma
15 | Self::Plasma
16 | Self::Turbo
17 | Self::Viridis
18 | Self::CyanToYellow
19 | Self::Spectral
20 | Self::Twilight => {}
21 }
22
23 match value {
24 v if v == Self::Grayscale as u8 => Some(Self::Grayscale),
25 v if v == Self::Inferno as u8 => Some(Self::Inferno),
26 v if v == Self::Magma as u8 => Some(Self::Magma),
27 v if v == Self::Plasma as u8 => Some(Self::Plasma),
28 v if v == Self::Turbo as u8 => Some(Self::Turbo),
29 v if v == Self::Viridis as u8 => Some(Self::Viridis),
30 v if v == Self::CyanToYellow as u8 => Some(Self::CyanToYellow),
31 v if v == Self::Spectral as u8 => Some(Self::Spectral),
32 v if v == Self::Twilight as u8 => Some(Self::Twilight),
33 _ => None,
34 }
35 }
36
37 pub fn category(&self) -> ColormapCategory {
39 ColormapCategory::from_colormap(*self)
40 }
41}