UNPKG

1.85 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.shearY = exports.shearX = void 0;
4function cot(theta) {
5 return 1 / Math.tan(theta);
6}
7/**
8 * Applies shear transformation for the first dimension of vector2.
9 * @param params [tx, ty]
10 * @param x x of the the bounding box of coordinate
11 * @param y y of the the bounding box of coordinate
12 * @param width width of the the bounding box of coordinate
13 * @param height height of the the bounding box of coordinate
14 * @returns transformer
15 */
16var shearX = function (params, x, y, width, height) {
17 var theta = params[0];
18 var sx = cot(theta);
19 return {
20 transform: function (vector) {
21 var x = vector[0], y = vector[1];
22 var xx = x + y * sx;
23 return [xx, y];
24 },
25 untransform: function (vector) {
26 var xx = vector[0], y = vector[1];
27 var x = xx - y * sx;
28 return [x, y];
29 },
30 };
31};
32exports.shearX = shearX;
33/**
34 * Applies shear transformation for the second dimension of vector2.
35 * @param params [tx, ty]
36 * @param x x of the the bounding box of coordinate
37 * @param y y of the the bounding box of coordinate
38 * @param width width of the the bounding box of coordinate
39 * @param height height of the the bounding box of coordinate
40 * @returns transformer
41 */
42var shearY = function (params, x, y, width, height) {
43 var theta = params[0];
44 var sy = cot(theta);
45 return {
46 transform: function (vector) {
47 var x = vector[0], y = vector[1];
48 var yy = y + x * sy;
49 return [x, yy];
50 },
51 untransform: function (vector) {
52 var x = vector[0], yy = vector[1];
53 var y = yy - x * sy;
54 return [x, y];
55 },
56 };
57};
58exports.shearY = shearY;
59//# sourceMappingURL=shear.js.map
\No newline at end of file