@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.
49 lines • 1.51 kB
JavaScript
import { Utils } from "../ColorsOld";
import { Color } from "./Color";
import { ColorSpace } from "./ColorSpace";
import { Ink } from "./Ink";
import { validateComponent } from "./ValidationUtils";
export class SpotColor extends Color {
constructor(ink, tint, alpha = 255) {
super();
this._colorSpace = ColorSpace.Spot;
this._ink = ink;
this._tint = validateComponent(tint);
this._alpha = validateComponent(alpha);
}
get ink() {
return this._ink;
}
get tint() {
return this._tint;
}
get alpha() {
return this._alpha;
}
get isTransparent() {
return this.alpha === 0;
}
equals(other) {
const spotOther = other;
return super.equals(other)
&& Ink.equals(this.ink, spotOther.ink)
&& this.tint === spotOther.tint
&& this.alpha === spotOther.alpha;
}
clone() {
return new SpotColor(this.ink.clone(), this.tint, this.alpha);
}
getData() {
const data = super.getData();
data.ink = this.ink.getData();
data.tint = this.tint;
data.alpha = this.alpha;
return data;
}
toString() {
const altColor = this.ink.alternativeColor.toString();
const tint = Utils.convertByteToPercent(this.tint);
return `spot('${this.ink.name}',${altColor},${this.ink.solidity},${tint})`;
}
}
//# sourceMappingURL=SpotColor.js.map