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.

165 lines 5.78 kB
import { RectangleF } from "../Math/RectangleF"; import { Color, RgbColors } from "../Colors"; import { CornerRadiusConverter } from "./Convert/CornerRadiusConverter"; import { EventWithSenderArg } from "../EventObject"; import * as Math from "../Math/index"; import { Margin } from "../Math/Margin"; export var PdfBox; (function (PdfBox) { PdfBox["Crop"] = "Crop"; PdfBox["Trim"] = "Trim"; PdfBox["Bleed"] = "Bleed"; })(PdfBox || (PdfBox = {})); var SafetyLine = /** @class */ (function () { function SafetyLine(properties) { this._propertyChanged = new EventWithSenderArg(); this._name = "bleed"; this._widthPx = 1; this._color = RgbColors.white; this._altColor = RgbColors.black; this._stepPx = 10; this._margin = new Margin(10); this._borderRadius = null; this._pdfBox = null; if (properties != null) Object.assign(this, properties); } Object.defineProperty(SafetyLine.prototype, "name", { get: function () { return this._name; }, set: function (value) { if (this._name === value) return; this._name = value; this._propertyChanged.notify(this, "name"); }, enumerable: true, configurable: true }); Object.defineProperty(SafetyLine.prototype, "widthPx", { get: function () { return this._widthPx; }, set: function (value) { if (Math.EqualsOfFloatNumbers(this._widthPx, value)) return; this._widthPx = value; this._propertyChanged.notify(this, "widthPx"); }, enumerable: true, configurable: true }); Object.defineProperty(SafetyLine.prototype, "color", { get: function () { return this._color; }, set: function (value) { if (Color.equals(this._color, value)) return; this._color = value; this._propertyChanged.notify(this, "color"); }, enumerable: true, configurable: true }); Object.defineProperty(SafetyLine.prototype, "altColor", { get: function () { return this._altColor; }, set: function (value) { if (Color.equals(this._altColor, value)) return; this._altColor = value; this._propertyChanged.notify(this, "altColor"); }, enumerable: true, configurable: true }); Object.defineProperty(SafetyLine.prototype, "margin", { get: function () { return this._margin; }, set: function (value) { if (typeof value === "number") value = new Margin(value); this._margin = value; this._propertyChanged.notify(this, "margin"); }, enumerable: true, configurable: true }); SafetyLine.prototype.getMargin = function () { return this._margin; }; Object.defineProperty(SafetyLine.prototype, "stepPx", { get: function () { return this._stepPx; }, set: function (value) { if (Math.EqualsOfFloatNumbers(this._stepPx, value)) return; this._stepPx = value; this._propertyChanged.notify(this, "stepPx"); }, enumerable: true, configurable: true }); Object.defineProperty(SafetyLine.prototype, "borderRadius", { get: function () { return this._borderRadius; }, set: function (value) { if (this._borderRadius === value) return; this._borderRadius = value; this._propertyChanged.notify(this, "borderRadius"); }, enumerable: true, configurable: true }); Object.defineProperty(SafetyLine.prototype, "pdfBox", { get: function () { return this._pdfBox; }, set: function (value) { if (this._pdfBox === value) return; this._pdfBox = value; this._propertyChanged.notify(this, "pdfBox"); }, enumerable: true, configurable: true }); SafetyLine.prototype.getRectangle = function (bounds) { var margin = this.getMargin(); return RectangleF.FromLTRB(bounds.left + margin.left, bounds.top + margin.top, bounds.right - margin.right, bounds.bottom - margin.bottom); }; SafetyLine.prototype.getCornerRadiuses = function (bounds) { if (this.borderRadius == null) return null; return new CornerRadiusConverter(this.getRectangle(bounds), 72).convert(this.borderRadius); }; SafetyLine.prototype.addPropertyChanged = function (listener) { this._propertyChanged.add(listener); }; SafetyLine.prototype.removePropertyChanged = function (listener) { this._propertyChanged.remove(listener); }; SafetyLine.prototype.clone = function () { var _a; var clone = new SafetyLine(); clone.name = this.name; clone.widthPx = this.widthPx; clone.color = this.color.clone(); clone.altColor = this.altColor.clone(); clone.stepPx = this.stepPx; clone.borderRadius = this.borderRadius; clone.pdfBox = this.pdfBox; clone.margin = (_a = this._margin) === null || _a === void 0 ? void 0 : _a.clone(); return clone; }; return SafetyLine; }()); export { SafetyLine }; //# sourceMappingURL=SafetyLine.js.map