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.

131 lines 4.14 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 = {})); export class SafetyLine { get name() { return this._name; } set name(value) { if (this._name === value) return; this._name = value; this._propertyChanged.notify(this, "name"); } get widthPx() { return this._widthPx; } set widthPx(value) { if (Math.EqualsOfFloatNumbers(this._widthPx, value)) return; this._widthPx = value; this._propertyChanged.notify(this, "widthPx"); } get color() { return this._color; } set color(value) { if (Color.equals(this._color, value)) return; this._color = value; this._propertyChanged.notify(this, "color"); } get altColor() { return this._altColor; } set altColor(value) { if (Color.equals(this._altColor, value)) return; this._altColor = value; this._propertyChanged.notify(this, "altColor"); } get margin() { return this._margin; } set margin(value) { if (typeof value === "number") value = new Margin(value); this._margin = value; this._propertyChanged.notify(this, "margin"); } getMargin() { return this._margin; } get stepPx() { return this._stepPx; } set stepPx(value) { if (Math.EqualsOfFloatNumbers(this._stepPx, value)) return; this._stepPx = value; this._propertyChanged.notify(this, "stepPx"); } get borderRadius() { return this._borderRadius; } set borderRadius(value) { if (this._borderRadius === value) return; this._borderRadius = value; this._propertyChanged.notify(this, "borderRadius"); } get pdfBox() { return this._pdfBox; } set pdfBox(value) { if (this._pdfBox === value) return; this._pdfBox = value; this._propertyChanged.notify(this, "pdfBox"); } constructor(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); } getRectangle(bounds) { const margin = this.getMargin(); return RectangleF.FromLTRB(bounds.left + margin.left, bounds.top + margin.top, bounds.right - margin.right, bounds.bottom - margin.bottom); } getCornerRadiuses(bounds) { if (this.borderRadius == null) return null; return new CornerRadiusConverter(this.getRectangle(bounds), 72).convert(this.borderRadius); } addPropertyChanged(listener) { this._propertyChanged.add(listener); } removePropertyChanged(listener) { this._propertyChanged.remove(listener); } clone() { var _a; const 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; } } //# sourceMappingURL=SafetyLine.js.map