UNPKG

@daign/2d-pipeline

Version:
81 lines (80 loc) 2.89 kB
"use strict"; 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.MatrixTransform = void 0; var math_1 = require("@daign/math"); var transform_1 = require("./transform"); /** * A transformation defined by a matrix. */ var MatrixTransform = /** @class */ (function (_super) { __extends(MatrixTransform, _super); /** * Constructor. */ function MatrixTransform() { var _this = _super.call(this) || this; /** * The transformation matrix. */ _this._matrix = new math_1.Matrix3().setIdentity(); // Notify observers when matrix has changes. var callback = function () { _this.notifyObservers(); }; _this._matrix.subscribeToChanges(callback); return _this; } Object.defineProperty(MatrixTransform.prototype, "matrix", { /** * Getter for the transformation matrix. * @returns The transformation matrix. */ get: function () { return this._matrix; }, enumerable: false, configurable: true }); Object.defineProperty(MatrixTransform.prototype, "matrixNonNative", { /** * Getter for the transformation matrix, not including native transforms. * @returns The transformation matrix. */ get: function () { /* Since this class is not a native transform, the non native matrix is identical to the normal * matrix. */ return this._matrix; }, enumerable: false, configurable: true }); Object.defineProperty(MatrixTransform.prototype, "nativeSvgTransform", { /** * Getter for the native SVG transform command string. * @returns The transform command string or null. */ get: function () { // The 3x3 matrix transform does not have a native SVG equivalent. return null; }, enumerable: false, configurable: true }); return MatrixTransform; }(transform_1.Transform)); exports.MatrixTransform = MatrixTransform;