1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::{c_api, NcPixel, NcRgb};
impl NcPixel {
pub fn new(value: c_api::NcPixel_u32) -> Self {
Self(value)
}
pub fn from_rgb(rgb: impl Into<NcRgb>) -> Self {
let (r, g, b) = rgb.into().into();
c_api::ncpixel(r, g, b).into()
}
pub fn a(self) -> u8 {
c_api::ncpixel_a(self.into())
}
pub fn b(self) -> u8 {
c_api::ncpixel_b(self.into())
}
pub fn g(self) -> u8 {
c_api::ncpixel_g(self.into())
}
pub fn r(self) -> u8 {
c_api::ncpixel_r(self.into())
}
pub fn set_a(&mut self, alpha: u8) {
c_api::ncpixel_set_a(self.into(), alpha)
}
pub fn set_g(&mut self, green: u8) {
c_api::ncpixel_set_b(self.into(), green)
}
pub fn set_b(&mut self, blue: u8) {
c_api::ncpixel_set_b(self.into(), blue)
}
pub fn set_r(&mut self, red: u8) {
c_api::ncpixel_set_r(self.into(), red)
}
pub fn set_rgb(&mut self, rgb: impl Into<NcRgb>) {
let (r, g, b) = rgb.into().into();
c_api::ncpixel_set_rgb8(self.into(), r, g, b);
}
}