medsurf-draw
Version:
Draw annotations on jpg/zoomify images, based on PIXI.js
101 lines • 3.74 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 (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 { BaseGraphics, BaseGraphicsModel } from "../../bases/elements/BaseGraphics";
var ArrowModel = (function (_super) {
__extends(ArrowModel, _super);
function ArrowModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.options = { hasLine: true, lineColor: 0xFFFFFF, lineAlpha: 1, hasFill: false };
_this.lineWidth = 1;
return _this;
}
return ArrowModel;
}(BaseGraphicsModel));
export { ArrowModel };
var Arrow = (function (_super) {
__extends(Arrow, _super);
function Arrow(model) {
return _super.call(this, model) || this;
}
Arrow.prototype.init = function () {
this.sortChildren();
this.emit("debounceDraw");
};
Arrow.prototype.draw = function () {
if (!this._geometry) {
return;
}
this.clear();
var polygon = [];
polygon.push(new PIXI.Point(this.rectangle.x, this.rectangle.y + this.rectangle.height / 2), new PIXI.Point(this.rectangle.x + this.rectangle.width, this.rectangle.y));
if (this.wedgePoint) {
polygon.push(new PIXI.Point(this.wedgePoint.x, this.wedgePoint.y));
}
polygon.push(new PIXI.Point(this.rectangle.x + this.rectangle.width, this.rectangle.y + this.rectangle.height), new PIXI.Point(this.rectangle.x, this.rectangle.y + this.rectangle.height / 2));
if (this.options.hasLine) {
this.lineStyle(this.lineWidth || 0, this.options.lineColor, this.options.lineAlpha, 0.5);
}
if (this.options.hasFill) {
this.beginFill(this.options.fillColor, this.options.fillAlpha);
}
this.drawPolygon(polygon);
this.endFill();
};
Object.defineProperty(Arrow.prototype, "rectangle", {
get: function () {
return this.data.rectangle;
},
set: function (value) {
this.data.rectangle = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Arrow.prototype, "wedgePoint", {
get: function () {
return this.data.wedgePoint;
},
set: function (value) {
this.data.wedgePoint = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Arrow.prototype, "options", {
get: function () {
return this.data.options;
},
set: function (value) {
this.data.options = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Arrow.prototype, "lineWidth", {
get: function () {
return this.data.lineWidth;
},
set: function (value) {
this.data.lineWidth = value;
},
enumerable: false,
configurable: true
});
return Arrow;
}(BaseGraphics));
export { Arrow };
//# sourceMappingURL=Arrow.js.map