UNPKG

@aurigma/design-atoms-model

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

36 lines 1.1 kB
import { ColorSpace } from "./ColorSpace"; import { ProcessColor } from "./ProcessColor"; import { validateComponent } from "./ValidationUtils"; export class GrayscaleColor extends ProcessColor { constructor(value, alpha, profile = null) { super(alpha, profile); this._colorSpace = ColorSpace.Grayscale; this._l = validateComponent(value); } get l() { return this._l; } equals(other) { const grayscaleOther = other; return super.equals(other) && this.l === grayscaleOther.l; } clone() { return new GrayscaleColor(this.l, this.alpha, this.profile); } getData() { const data = super.getData(); data.l = this.l; return data; } toString() { if (this.alpha === 255) { return `rgb(${this.l},${this.l},${this.l})`; } else { const a = (this.alpha / 255).toFixed(7); return `rgba(${this.l},${this.l},${this.l},${a})`; } } } //# sourceMappingURL=GrayscaleColor.js.map