UNPKG

medsurf-draw

Version:

Draw annotations on jpg/zoomify images, based on PIXI.js

107 lines 4.56 kB
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import * as PIXI from "pixi.js-legacy"; import * as MedsurfDraw from "../../public-api"; import { Design } from "../../config/design"; import { BaseContainer, BaseContainerImageModel } from "../../bases/elements/BaseContainer"; var RoundButtonIndicatorElementModel = (function (_super) { __extends(RoundButtonIndicatorElementModel, _super); function RoundButtonIndicatorElementModel() { return _super !== null && _super.apply(this, arguments) || this; } return RoundButtonIndicatorElementModel; }(BaseContainerImageModel)); export { RoundButtonIndicatorElementModel }; var RoundButtonIndicatorElement = (function (_super) { __extends(RoundButtonIndicatorElement, _super); function RoundButtonIndicatorElement(model) { var _this = _super.call(this, model) || this; _this.zIndex = Design.menuButton.zIndex + 1; _this.position.set(_this.circle.x, _this.circle.y); return _this; } RoundButtonIndicatorElement.prototype.init = function (parent) { this.interactive = true; var lineWidth = this.lineWidth; if (lineWidth < Design.roundButtonIndicatorElement.minLineWidth) { lineWidth = Design.roundButtonIndicatorElement.minLineWidth; } this._arcElement = new MedsurfDraw.Arc({ center: new PIXI.Point(0, 0), options: this.options, radius: this.circle.radius, lineWidth: lineWidth, }); this._arcElement.angle = 225; this.addChild(this._arcElement); this.sortChildren(); this.emit("debounceDraw"); }; RoundButtonIndicatorElement.prototype.draw = function () { var lineWidth = this.lineWidth; if (lineWidth < Design.roundButtonIndicatorElement.minLineWidth) { lineWidth = Design.roundButtonIndicatorElement.minLineWidth; } this._arcElement.radius = this.circle.radius; this._arcElement.lineWidth = lineWidth; this._arcElement.draw(); }; RoundButtonIndicatorElement.prototype.destroy = function (options) { if (this._arcElement) { this._arcElement.destroy(options); } _super.prototype.destroy.call(this, options); }; Object.defineProperty(RoundButtonIndicatorElement.prototype, "circle", { get: function () { return this.data.circle || new PIXI.Circle(0, 0, 20); }, set: function (value) { this.data.circle = value; this._arcElement.radius = this.circle.radius; this.emit("debounceDraw"); }, enumerable: false, configurable: true }); Object.defineProperty(RoundButtonIndicatorElement.prototype, "options", { get: function () { return this.data.options || { hasLine: true, lineColor: Design.roundButtonIndicatorElement.lineColor, lineAlpha: Design.roundButtonIndicatorElement.lineAlpha, hasFill: false }; }, set: function (value) { this.data.options = value; this._arcElement.options = this.options; this.emit("debounceDraw"); }, enumerable: false, configurable: true }); Object.defineProperty(RoundButtonIndicatorElement.prototype, "lineWidth", { get: function () { return this.data.lineWidth || Design.roundButtonIndicatorElement.lineWidth; }, set: function (value) { this.data.lineWidth = value; this._arcElement.lineWidth = this.lineWidth; this.emit("debounceDraw"); }, enumerable: false, configurable: true }); return RoundButtonIndicatorElement; }(BaseContainer)); export { RoundButtonIndicatorElement }; //# sourceMappingURL=RoundButtonIndicatorElement.js.map