UNPKG

medsurf-draw

Version:

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

67 lines 2.6 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 { BaseText, BaseTextModel } from "../../bases/elements/BaseText"; import { Design } from "../../config/design"; var TextModel = (function (_super) { __extends(TextModel, _super); function TextModel() { return _super !== null && _super.apply(this, arguments) || this; } return TextModel; }(BaseTextModel)); export { TextModel }; var Text = (function (_super) { __extends(Text, _super); function Text(model) { return _super.call(this, model) || this; } Text.prototype.init = function () { this.sortChildren(); this.onImageZoom(1, 1); }; Text.prototype.onImageZoom = function (scaleX, scaleY) { var resolution = Math.round(scaleX); if (resolution < Design.text.minResolution) { resolution = Design.text.minResolution; } if (resolution > Design.text.maxResolution) { resolution = Design.text.maxResolution; } this.resolution = resolution; }; Text.prototype.getRectangle = function () { try { if (this.parent instanceof MedsurfDraw.TextPrimitive || this.parent instanceof MedsurfDraw.LegendRow) { return this.parent.getRectangle(); } return _super.prototype.getRectangle.call(this); } catch (e) { return new PIXI.Rectangle(this.position.x, this.position.y, 1, 1); } }; Text.prototype.getRotation = function () { if (this.parent instanceof MedsurfDraw.TextPrimitive || this.parent instanceof MedsurfDraw.LegendRow) { return this.parent.rotation; } return this.rotation; }; return Text; }(BaseText)); export { Text }; //# sourceMappingURL=Text.js.map