@daign/2d-graphics
Version:
Two dimensional graphics library that implements the daign-2d-pipeline.
39 lines (38 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoundingModifier = void 0;
/**
* Rounding modifier.
* Round the point coordinates to the given precision.
*/
var RoundingModifier = /** @class */ (function () {
/**
* Constructor.
* @param precision - The number of decimal places to round to. Optional.
*/
function RoundingModifier(precision) {
// Variable to temporarily disable the control modifier.
this.enabled = true;
this.precision = undefined;
if (precision) {
this.precision = precision;
}
}
/**
* Modify the position change that has been requested for a control object.
* @param updatedPoints - The array of updated points.
* @param pointIndex - The index of the point that initiated the change.
* @param controlObject - The corresponding control object.
* @returns The modified array of points.
*/
RoundingModifier.prototype.modifyPoints = function (updatedPoints, pointIndex, _controlObject) {
if (!this.enabled) {
return updatedPoints;
}
var targetPoint = updatedPoints[pointIndex];
targetPoint.round(this.precision);
return updatedPoints;
};
return RoundingModifier;
}());
exports.RoundingModifier = RoundingModifier;