use crate::*;
pub use sys::Pixel;
impl Default for Pixel {
fn default() -> Pixel {
Pixel::empty()
}
}
impl std::ops::Add for Pixel {
type Output = Pixel;
fn add(mut self, other: Pixel) -> Pixel {
unsafe {
sys::pixelAdd(&mut self, &other);
}
other
}
}
impl std::ops::Sub for Pixel {
type Output = Pixel;
fn sub(mut self, other: Pixel) -> Pixel {
unsafe {
sys::pixelSub(&mut self, &other);
}
other
}
}
impl std::ops::Mul for Pixel {
type Output = Pixel;
fn mul(mut self, other: Pixel) -> Pixel {
unsafe {
sys::pixelMul(&mut self, &other);
}
other
}
}
impl std::ops::Div for Pixel {
type Output = Pixel;
fn div(mut self, other: Pixel) -> Pixel {
unsafe {
sys::pixelDiv(&mut self, &other);
}
other
}
}
impl Pixel {
pub fn empty() -> Pixel {
unsafe { sys::pixelEmpty() }
}
pub fn new3(r: f32, g: f32, b: f32) -> Pixel {
unsafe { sys::pixelNew3(r, g, b) }
}
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Pixel {
unsafe { sys::pixelNew(r, g, b, a) }
}
pub fn gray(x: f32) -> Pixel {
unsafe { sys::pixelNew1(x) }
}
pub fn data(&self) -> [f32; 4] {
self.data
}
pub fn data_mut(&mut self) -> &mut [f32] {
&mut self.data
}
}