use oxivgl_sys::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug)]
pub enum Palette {
Red = 0,
Pink = 1,
Purple = 2,
DeepPurple = 3,
Indigo = 4,
Blue = 5,
LightBlue = 6,
Cyan = 7,
Teal = 8,
Green = 9,
LightGreen = 10,
Lime = 11,
Yellow = 12,
Amber = 13,
Orange = 14,
DeepOrange = 15,
Brown = 16,
BlueGrey = 17,
Grey = 18,
}
#[repr(u32)]
#[derive(Clone, Copy, Debug)]
pub enum GradDir {
None = 0,
Ver = 1,
Hor = 2,
Linear = 3,
Radial = 4,
Conical = 5,
}
pub fn palette_main(p: Palette) -> lv_color_t {
unsafe { lv_palette_main(p as lv_palette_t) }
}
pub fn palette_lighten(p: Palette, level: u8) -> lv_color_t {
unsafe { lv_palette_lighten(p as lv_palette_t, level) }
}
pub fn palette_darken(p: Palette, level: u8) -> lv_color_t {
unsafe { lv_palette_darken(p as lv_palette_t, level) }
}
pub fn color_white() -> lv_color_t {
unsafe { lv_color_white() }
}
pub fn color_black() -> lv_color_t {
unsafe { lv_color_black() }
}
pub fn color_make(r: u8, g: u8, b: u8) -> lv_color_t {
unsafe { lv_color_make(r, g, b) }
}
pub fn color_mix(c1: lv_color_t, c2: lv_color_t, mix: u8) -> lv_color_t {
unsafe { lv_color_mix(c1, c2, mix) }
}
pub fn color_brightness(c: lv_color_t) -> u8 {
unsafe { lv_color_brightness(c) }
}
pub fn color_darken(c: lv_color_t, lvl: u8) -> lv_color_t {
unsafe { lv_color_darken(c, lvl) }
}
pub fn color_hsv(h: u16, s: u8, v: u8) -> lv_color_t {
unsafe { lv_color_hsv_to_rgb(h, s, v) }
}
#[cfg(test)]
mod tests {
use super::{GradDir, Palette};
#[test]
fn palette_discriminants() {
assert_eq!(Palette::Red as u32, 0);
assert_eq!(Palette::Grey as u32, 18);
}
#[test]
fn grad_dir_discriminants() {
assert_eq!(GradDir::None as u32, 0);
assert_eq!(GradDir::Ver as u32, 1);
assert_eq!(GradDir::Hor as u32, 2);
assert_eq!(GradDir::Linear as u32, 3);
assert_eq!(GradDir::Radial as u32, 4);
assert_eq!(GradDir::Conical as u32, 5);
}
}