medsurf-draw
Version:
Draw annotations on jpg/zoomify images, based on PIXI.js
101 lines • 3.51 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';
import { debounce } from "debounce";
var ArcModel = (function (_super) {
__extends(ArcModel, _super);
function ArcModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ArcModel;
}(BaseGraphicsModel));
export { ArcModel };
var Arc = (function (_super) {
__extends(Arc, _super);
function Arc(model) {
var _this = _super.call(this, model) || this;
_this._debounceUpdateHitAreaMethod = debounce(_this.updateHitArea.bind(_this), 500).bind(_this);
_this.on("added", function () {
_this.on("debouncedUpdateHitArea", _this._debounceUpdateHitAreaMethod);
});
_this.on("removed", function () {
_this.off("debouncedUpdateHitArea", _this._debounceUpdateHitAreaMethod);
});
return _this;
}
Arc.prototype.init = function () {
this.sortChildren();
this.emit("debounceDraw");
};
Arc.prototype.draw = function () {
if (!this._geometry) {
return;
}
this.clear();
this.lineStyle(this.lineWidth, this.options.lineColor, this.options.lineAlpha, 0.6);
this.arc(this.center.x, this.center.y, this.radius, 0, Math.PI / 2);
this.emit("debouncedUpdateHitArea");
};
Arc.prototype.updateHitArea = function () {
if (!this._destroyed) {
this.hitArea = new PIXI.Polygon(this.geometry.points);
}
};
Object.defineProperty(Arc.prototype, "center", {
get: function () {
return this.data.center;
},
set: function (value) {
this.data.center = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Arc.prototype, "radius", {
get: function () {
return this.data.radius;
},
set: function (value) {
this.data.radius = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Arc.prototype, "options", {
get: function () {
return this.data.options;
},
set: function (value) {
this.data.options = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Arc.prototype, "lineWidth", {
get: function () {
return this.data.lineWidth;
},
set: function (value) {
this.data.lineWidth = value;
},
enumerable: false,
configurable: true
});
return Arc;
}(BaseGraphics));
export { Arc };
//# sourceMappingURL=Arc.js.map