-
Notifications
You must be signed in to change notification settings - Fork 12
/
Color.ts
31 lines (26 loc) · 876 Bytes
/
Color.ts
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
export class Color {
public static empty = new Color(0, 0, 0, 0);
public static transparent = new Color(0, 0, 0, 0);
public static black = new Color(255, 0, 0, 0);
public static white = new Color(255, 255, 255, 255);
public static whiteSmoke = new Color(255, 245, 245, 245);
public static fromArgb(a: number, r: number, g: number, b: number): Color {
return new Color(a, r, g, b);
}
public static fromRgb(r: number, g: number, b: number): Color {
return new Color(255, r, g, b);
}
public static fromArray(primitive: [number, number, number] | number[]): Color {
return new Color(255, primitive[0], primitive[1], primitive[2]);
}
public a: number;
public r: number;
public g: number;
public b: number;
constructor(a = 255, r: number, g: number, b: number) {
this.a = a;
this.r = r;
this.g = g;
this.b = b;
}
}