| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.shearY = exports.shearX = void 0;
- function cot(theta) {
- return 1 / Math.tan(theta);
- }
- /**
- * Applies shear transformation for the first dimension of vector2.
- * @param params [tx, ty]
- * @param x x of the the bounding box of coordinate
- * @param y y of the the bounding box of coordinate
- * @param width width of the the bounding box of coordinate
- * @param height height of the the bounding box of coordinate
- * @returns transformer
- */
- var shearX = function (params, x, y, width, height) {
- var theta = params[0];
- var sx = cot(theta);
- return {
- transform: function (vector) {
- var x = vector[0], y = vector[1];
- var xx = x + y * sx;
- return [xx, y];
- },
- untransform: function (vector) {
- var xx = vector[0], y = vector[1];
- var x = xx - y * sx;
- return [x, y];
- },
- };
- };
- exports.shearX = shearX;
- /**
- * Applies shear transformation for the second dimension of vector2.
- * @param params [tx, ty]
- * @param x x of the the bounding box of coordinate
- * @param y y of the the bounding box of coordinate
- * @param width width of the the bounding box of coordinate
- * @param height height of the the bounding box of coordinate
- * @returns transformer
- */
- var shearY = function (params, x, y, width, height) {
- var theta = params[0];
- var sy = cot(theta);
- return {
- transform: function (vector) {
- var x = vector[0], y = vector[1];
- var yy = y + x * sy;
- return [x, yy];
- },
- untransform: function (vector) {
- var x = vector[0], yy = vector[1];
- var y = yy - x * sy;
- return [x, y];
- },
- };
- };
- exports.shearY = shearY;
- //# sourceMappingURL=shear.js.map
|