web_view/
color.rs

1/// An RGBA color.
2#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
3pub struct Color {
4    pub r: u8,
5    pub g: u8,
6    pub b: u8,
7    pub a: u8,
8}
9
10impl From<(u8, u8, u8, u8)> for Color {
11    fn from(tuple: (u8, u8, u8, u8)) -> Color {
12        Color {
13            r: tuple.0,
14            g: tuple.1,
15            b: tuple.2,
16            a: tuple.3,
17        }
18    }
19}
20
21impl From<(u8, u8, u8)> for Color {
22    fn from(tuple: (u8, u8, u8)) -> Color {
23        Color {
24            r: tuple.0,
25            g: tuple.1,
26            b: tuple.2,
27            a: 255,
28        }
29    }
30}
31
32impl From<[u8; 4]> for Color {
33    fn from(array: [u8; 4]) -> Color {
34        Color {
35            r: array[0],
36            g: array[1],
37            b: array[2],
38            a: array[3],
39        }
40    }
41}
42
43impl From<[u8; 3]> for Color {
44    fn from(array: [u8; 3]) -> Color {
45        Color {
46            r: array[0],
47            g: array[1],
48            b: array[2],
49            a: 255,
50        }
51    }
52}