use crate::{c_api, error, Nc, NcPalette, NcPaletteIndex, NcResult, NcRgb};
impl NcPalette {
pub fn new<'a>(nc: &mut Nc) -> &'a mut Self {
unsafe { &mut *c_api::ncpalette_new(nc) }
}
pub fn free(&mut self) {
unsafe {
c_api::ncpalette_free(self);
}
}
pub fn r#use(&self, nc: &mut Nc) -> NcResult<()> {
error![unsafe { c_api::ncpalette_use(nc, self) }]
}
pub fn get(&self, index: impl Into<NcPaletteIndex>) -> NcRgb {
c_api::ncpalette_get(self, index.into()).into()
}
pub fn set(&mut self, index: impl Into<NcPaletteIndex>, rgb: impl Into<NcRgb>) {
c_api::ncpalette_set(self, index.into(), rgb.into().into())
}
}