-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.cs
More file actions
47 lines (40 loc) · 1.03 KB
/
Color.cs
File metadata and controls
47 lines (40 loc) · 1.03 KB
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
public class Color {
public byte Red;
public byte Green;
public byte Blue;
public byte Alpha;
public static Color Transparent = new Color(0, 0, 0, 0);
public Color(byte red, byte green, byte blue, byte alpha) {
Red = red;
Green = green;
Blue = blue;
Alpha = alpha;
}
public Color(byte red, byte green, byte blue) {
Red = red;
Green = green;
Blue = blue;
Alpha = 0xFF;
}
public Color(byte value, byte alpha) {
Red = value;
Green = value;
Blue = value;
Alpha = alpha;
}
public Color(byte index) {
Red = index;
Green = 0;
Blue = 0;
Alpha = 0xFF;
}
public Color(uint argb) {
Alpha = (byte)((argb & 0xFF000000) >> 24);
Blue = (byte)((argb & 0xFF0000) >> 16);
Green = (byte)((argb & 0xFF00) >> 8);
Red = (byte)(argb & 0xFF);
}
public uint ToABGR() {
return (uint)(Alpha << 24 | Blue << 16 | Green << 8 | Red);
}
}