export class MarkupColor { public R: number; public G: number; public B: number; private _hex: string; /** * Color in #000000 format */ get HexColor(): string { return "#" + this._hex; } get RGB(): { r: number; g: number; b: number } { return { r: this.R, g: this.G, b: this.B }; } constructor(r: number, g: number, b: number) { this.setColor(r, g, b); } public setColor(r: number, g: number, b: number): void { this.R = r; this.G = g; this.B = b; this._hex = this.rgbToHex(r, g, b); } private rgbToHex(r: number, g: number, b: number): string { const valueToHex = (c) => { const hex = c.toString(16); return hex === "0" ? "00" : hex; }; return valueToHex(r) + valueToHex(g) + valueToHex(b); } }