@mlightcad/geometry-engine
Version:
The geometry-engine package provides comprehensive geometric entities, mathematical operations, and transformations for 2D and 3D space. This package mimics AutoCAD ObjectARX's AcGe (Geometry) classes and provides the mathematical foundation for CAD opera
51 lines • 2.09 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 { AcGeMatrix2d } from '../math';
import { AcGeShape } from './AcGeShape';
/**
* Abstract base class for all kinds of 2d shapes.
*/
var AcGeShape2d = /** @class */ (function (_super) {
__extends(AcGeShape2d, _super);
function AcGeShape2d() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Return new shape translated by given vector.
*/
AcGeShape2d.prototype.translate = function (v) {
return this.transform(new AcGeMatrix2d().makeTranslation(v.x, v.y));
};
Object.defineProperty(AcGeShape2d.prototype, "box", {
/**
* The bounding box of this shape. Because it is a time-consuming operation to calculate the bounding
* box of one shape, the bounding box value is cached. It will be calculated again lazily once there
* are any changes to properties of this shape.
*/
get: function () {
if (this._box == null || this._boundingBoxNeedsUpdate) {
this._box = this.calculateBoundingBox();
this._boundingBoxNeedsUpdate = false;
}
return this._box;
},
enumerable: false,
configurable: true
});
return AcGeShape2d;
}(AcGeShape));
export { AcGeShape2d };
//# sourceMappingURL=AcGeShape2d.js.map