@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.
51 lines • 1.58 kB
JavaScript
import { ColorSpace } from "./ColorSpace";
import { ProcessColor } from "./ProcessColor";
import { validateComponent } from "./ValidationUtils";
export class CmykColor extends ProcessColor {
constructor(c, m, y, k, alpha, profile = null) {
super(alpha, profile);
this._colorSpace = ColorSpace.Cmyk;
this._c = validateComponent(c);
this._m = validateComponent(m);
this._y = validateComponent(y);
this._k = validateComponent(k);
}
get c() {
return this._c;
}
get m() {
return this._m;
}
get y() {
return this._y;
}
get k() {
return this._k;
}
equals(other) {
const cmykOther = other;
return super.equals(other)
&& this.c === cmykOther.c
&& this.m === cmykOther.m
&& this.y === cmykOther.y
&& this.k === cmykOther.k;
}
clone() {
return new CmykColor(this.c, this.m, this.y, this.k, this.alpha, this.profile);
}
getData() {
const data = super.getData();
data.c = this.c;
data.m = this.m;
data.y = this.y;
data.k = this.k;
return data;
}
toString() {
return "cmyk(".concat(`${this._toRelative(this.c)},`, `${this._toRelative(this.m)},`, `${this._toRelative(this.y)},`, `${this._toRelative(this.k)},`, `${this._toRelative(this.alpha)})`);
}
_toRelative(component) {
return (component / 255).toFixed(7);
}
}
//# sourceMappingURL=CmykColor.js.map