123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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
- */
- export 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];
- },
- };
- };
- /**
- * 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
- */
- export 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];
- },
- };
- };
- //# sourceMappingURL=shear.js.map
|