@daign/2d-graphics
Version:
Two dimensional graphics library that implements the daign-2d-pipeline.
77 lines (76 loc) • 2.73 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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Line = void 0;
var styledGraphicNode_1 = require("../styledGraphicNode");
/**
* Class for a line segment element.
*/
var Line = /** @class */ (function (_super) {
__extends(Line, _super);
/**
* Constructor.
*/
function Line() {
var _this = _super.call(this) || this;
_this.baseClass = 'line';
_this.points.initializeElements(2);
_this.points.assignName('start', 0);
_this.points.assignName('end', 1);
return _this;
}
Object.defineProperty(Line.prototype, "start", {
get: function () {
return this.points.getByName('start');
},
set: function (position) {
this.points.getByName('start').copy(position);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Line.prototype, "end", {
get: function () {
return this.points.getByName('end');
},
set: function (position) {
this.points.getByName('end').copy(position);
},
enumerable: false,
configurable: true
});
/**
* Calculate the start after a given transformation.
* @param transformation - The transformation to apply.
* @returns The transformed start position.
*/
Line.prototype.getStartTransformed = function (transformation) {
var startPoint = this.start.clone().transform(transformation);
return startPoint;
};
/**
* Calculate the end after a given transformation.
* @param transformation - The transformation to apply.
* @returns The transformed end position.
*/
Line.prototype.getEndTransformed = function (transformation) {
var endPoint = this.end.clone().transform(transformation);
return endPoint;
};
return Line;
}(styledGraphicNode_1.StyledGraphicNode));
exports.Line = Line;