@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.
58 lines • 2.3 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { ColorSpace } from "./ColorSpace";
import { ProcessColor } from "./ProcessColor";
import { validateComponent } from "./ValidationUtils";
var GrayscaleColor = /** @class */ (function (_super) {
__extends(GrayscaleColor, _super);
function GrayscaleColor(value, alpha, profile) {
if (profile === void 0) { profile = null; }
var _this = _super.call(this, alpha, profile) || this;
_this._colorSpace = ColorSpace.Grayscale;
_this._l = validateComponent(value);
return _this;
}
Object.defineProperty(GrayscaleColor.prototype, "l", {
get: function () {
return this._l;
},
enumerable: true,
configurable: true
});
GrayscaleColor.prototype.equals = function (other) {
var grayscaleOther = other;
return _super.prototype.equals.call(this, other)
&& this.l === grayscaleOther.l;
};
GrayscaleColor.prototype.clone = function () {
return new GrayscaleColor(this.l, this.alpha, this.profile);
};
GrayscaleColor.prototype.getData = function () {
var data = _super.prototype.getData.call(this);
data.l = this.l;
return data;
};
GrayscaleColor.prototype.toString = function () {
if (this.alpha === 255) {
return "rgb(" + this.l + "," + this.l + "," + this.l + ")";
}
else {
var a = (this.alpha / 255).toFixed(7);
return "rgba(" + this.l + "," + this.l + "," + this.l + "," + a + ")";
}
};
return GrayscaleColor;
}(ProcessColor));
export { GrayscaleColor };
//# sourceMappingURL=GrayscaleColor.js.map