This commit is contained in:
Timo Hocker 2020-04-27 13:51:28 +02:00
parent 3eb70b10ed
commit 38065b3fc7

View File

@ -13,10 +13,10 @@ export class Color {
public static readonly transparent = new Color (0, 0, 0, 0);
public static readonly gray = new Color (128, 128, 128);
private red: number;
private green: number;
private blue: number;
private alpha: number;
private _red: number;
private _green: number;
private _blue: number;
private _alpha: number;
private check_range (n: number): void {
if (n < 0 || n > 255)
@ -28,25 +28,25 @@ export class Color {
this.check_range (green);
this.check_range (blue);
this.check_range (alpha);
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
this._red = red;
this._green = green;
this._blue = blue;
this._alpha = alpha;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
public toString (): string {
return `#${num_to_hex (
this.red,
this._red,
2
)}${num_to_hex (
this.green,
this._green,
2
)}${num_to_hex (
this.blue,
this._blue,
2
)}${this.alpha === 255
)}${this._alpha === 255
? ''
: num_to_hex (this.alpha, 2)}`;
: num_to_hex (this._alpha, 2)}`;
}
}