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
61
62
63
64
65
66
67
68
use std::ops::{Deref, DerefMut};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ColorType {
Rgb,
Rgba,
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Pixel(pub [u8; 4]);
impl Deref for Pixel {
type Target = [u8];
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for Pixel {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
pub static WHITE: Pixel = Pixel([255, 255, 255, 255]);
pub static BLACK: Pixel = Pixel([0, 0, 0, 255]);
pub static TRANSPARENT: Pixel = Pixel([0, 0, 0, 0]);
pub static GRAY: Pixel = Pixel([192, 192, 192, 255]);
pub static DARK_GRAY: Pixel = Pixel([128, 128, 128, 255]);
pub static VERY_DARK_GRAY: Pixel = Pixel([64, 64, 64, 255]);
pub static RED: Pixel = Pixel([255, 0, 0, 255]);
pub static DARK_RED: Pixel = Pixel([128, 0, 0, 255]);
pub static VERY_DARK_RED: Pixel = Pixel([64, 0, 0, 255]);
pub static ORANGE: Pixel = Pixel([255, 128, 0, 255]);
pub static YELLOW: Pixel = Pixel([255, 255, 0, 255]);
pub static DARK_YELLOW: Pixel = Pixel([128, 128, 0, 255]);
pub static VERY_DARK_YELLOW: Pixel = Pixel([64, 64, 0, 255]);
pub static GREEN: Pixel = Pixel([0, 255, 0, 255]);
pub static DARK_GREEN: Pixel = Pixel([0, 128, 0, 255]);
pub static VERY_DARK_GREEN: Pixel = Pixel([0, 64, 0, 255]);
pub static CYAN: Pixel = Pixel([0, 255, 255, 255]);
pub static DARK_CYAN: Pixel = Pixel([0, 128, 128, 255]);
pub static VERY_DARK_CYAN: Pixel = Pixel([0, 64, 64, 255]);
pub static BLUE: Pixel = Pixel([0, 0, 255, 255]);
pub static DARK_BLUE: Pixel = Pixel([0, 0, 128, 255]);
pub static VERY_DARK_BLUE: Pixel = Pixel([0, 0, 64, 255]);
pub static MAGENTA: Pixel = Pixel([255, 0, 255, 255]);
pub static DARK_MAGENTA: Pixel = Pixel([128, 0, 128, 255]);
pub static VERY_DARK_MAGENTA: Pixel = Pixel([64, 0, 64, 255]);