@zag-js/rect-utils 1.47.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
- package/dist/affine-transform.d.mts +36 -39
- package/dist/affine-transform.d.ts +36 -39
- package/dist/affine-transform.js +189 -187
- package/dist/affine-transform.mjs +185 -164
- package/dist/align.d.mts +2 -5
- package/dist/align.d.ts +2 -5
- package/dist/align.js +27 -44
- package/dist/align.mjs +23 -21
- package/dist/angle.d.mts +2 -5
- package/dist/angle.d.ts +2 -5
- package/dist/angle.js +8 -32
- package/dist/angle.mjs +4 -9
- package/dist/clamp.d.mts +8 -11
- package/dist/clamp.d.ts +8 -11
- package/dist/clamp.js +23 -46
- package/dist/clamp.mjs +18 -22
- package/dist/closest.d.mts +4 -7
- package/dist/closest.d.ts +4 -7
- package/dist/closest.js +35 -62
- package/dist/closest.mjs +29 -37
- package/dist/compass.d.mts +4 -7
- package/dist/compass.d.ts +4 -7
- package/dist/compass.js +48 -48
- package/dist/compass.mjs +43 -24
- package/dist/constrain.d.mts +2 -5
- package/dist/constrain.d.ts +2 -5
- package/dist/constrain.js +12 -37
- package/dist/constrain.mjs +8 -14
- package/dist/contains.d.mts +4 -7
- package/dist/contains.d.ts +4 -7
- package/dist/contains.js +11 -36
- package/dist/contains.mjs +5 -11
- package/dist/distance.d.mts +7 -10
- package/dist/distance.d.ts +7 -10
- package/dist/distance.js +55 -60
- package/dist/distance.mjs +48 -34
- package/dist/equality.d.mts +4 -7
- package/dist/equality.d.ts +4 -7
- package/dist/equality.js +13 -38
- package/dist/equality.mjs +7 -13
- package/dist/from-element.d.mts +12 -15
- package/dist/from-element.d.ts +12 -15
- package/dist/from-element.js +39 -58
- package/dist/from-element.mjs +35 -35
- package/dist/from-points.d.mts +2 -5
- package/dist/from-points.d.ts +2 -5
- package/dist/from-points.js +18 -36
- package/dist/from-points.mjs +14 -13
- package/dist/from-range.d.mts +2 -5
- package/dist/from-range.d.ts +2 -5
- package/dist/from-range.js +25 -46
- package/dist/from-range.mjs +19 -21
- package/dist/from-rotation.d.mts +4 -7
- package/dist/from-rotation.d.ts +4 -7
- package/dist/from-rotation.js +31 -56
- package/dist/from-rotation.mjs +25 -31
- package/dist/from-window.d.mts +13 -16
- package/dist/from-window.d.ts +13 -16
- package/dist/from-window.js +29 -44
- package/dist/from-window.mjs +24 -20
- package/dist/index.d.mts +22 -22
- package/dist/index.d.ts +22 -22
- package/dist/index.js +72 -63
- package/dist/index.mjs +21 -22
- package/dist/intersection.d.mts +4 -7
- package/dist/intersection.d.ts +4 -7
- package/dist/intersection.js +34 -45
- package/dist/intersection.mjs +28 -20
- package/dist/operations.d.mts +6 -9
- package/dist/operations.d.ts +6 -9
- package/dist/operations.js +38 -57
- package/dist/operations.mjs +30 -30
- package/dist/polygon.d.mts +6 -9
- package/dist/polygon.d.ts +6 -9
- package/dist/polygon.js +73 -82
- package/dist/polygon.mjs +67 -57
- package/dist/rect.d.mts +49 -52
- package/dist/rect.d.ts +49 -52
- package/dist/rect.js +57 -82
- package/dist/rect.mjs +46 -52
- package/dist/resize.d.mts +3 -6
- package/dist/resize.d.ts +3 -6
- package/dist/resize.js +73 -102
- package/dist/resize.mjs +68 -78
- package/dist/types.d.mts +45 -49
- package/dist/types.d.ts +45 -49
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/dist/union.d.mts +2 -5
- package/dist/union.d.ts +2 -5
- package/dist/union.js +16 -39
- package/dist/union.mjs +12 -16
- package/package.json +3 -3
- package/dist/chunk-QZ7TP4HQ.mjs +0 -7
package/dist/rect.d.ts
CHANGED
|
@@ -1,58 +1,55 @@
|
|
|
1
|
-
import { Point,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Point, Rect, RectEdge, RectInit } from "./types.js";
|
|
2
|
+
export declare const createPoint: (x: number, y: number) => {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const subtractPoints: (a: Point, b: Point | null) => Point;
|
|
7
|
+
export declare const addPoints: (a: Point, b: Point) => {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function isPoint(v: any): v is Point;
|
|
12
|
+
export declare function createRect(r: RectInit): Rect;
|
|
13
|
+
export declare function isRect(v: any): v is Rect;
|
|
14
|
+
export declare function getRectCenters(v: Rect): {
|
|
15
|
+
top: {
|
|
4
16
|
x: number;
|
|
5
17
|
y: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare const addPoints: (a: Point, b: Point) => {
|
|
18
|
+
};
|
|
19
|
+
right: {
|
|
9
20
|
x: number;
|
|
10
21
|
y: number;
|
|
22
|
+
};
|
|
23
|
+
bottom: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
left: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
};
|
|
11
31
|
};
|
|
12
|
-
declare function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
x: number;
|
|
30
|
-
y: number;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
declare function getRectCorners(v: Rect): {
|
|
34
|
-
top: {
|
|
35
|
-
x: number;
|
|
36
|
-
y: number;
|
|
37
|
-
};
|
|
38
|
-
right: {
|
|
39
|
-
x: number;
|
|
40
|
-
y: number;
|
|
41
|
-
};
|
|
42
|
-
bottom: {
|
|
43
|
-
x: number;
|
|
44
|
-
y: number;
|
|
45
|
-
};
|
|
46
|
-
left: {
|
|
47
|
-
x: number;
|
|
48
|
-
y: number;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
declare function getRectEdges(v: Rect): {
|
|
52
|
-
top: RectEdge;
|
|
53
|
-
right: RectEdge;
|
|
54
|
-
bottom: RectEdge;
|
|
55
|
-
left: RectEdge;
|
|
32
|
+
export declare function getRectCorners(v: Rect): {
|
|
33
|
+
top: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
right: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
bottom: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
left: {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
};
|
|
56
49
|
};
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
export declare function getRectEdges(v: Rect): {
|
|
51
|
+
top: RectEdge;
|
|
52
|
+
right: RectEdge;
|
|
53
|
+
bottom: RectEdge;
|
|
54
|
+
left: RectEdge;
|
|
55
|
+
};
|
package/dist/rect.js
CHANGED
|
@@ -1,97 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
20
5
|
// src/rect.ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
createPoint: () => createPoint,
|
|
25
|
-
createRect: () => createRect,
|
|
26
|
-
getRectCenters: () => getRectCenters,
|
|
27
|
-
getRectCorners: () => getRectCorners,
|
|
28
|
-
getRectEdges: () => getRectEdges,
|
|
29
|
-
isPoint: () => isPoint,
|
|
30
|
-
isRect: () => isRect,
|
|
31
|
-
subtractPoints: () => subtractPoints
|
|
6
|
+
const createPoint = (x, y) => ({
|
|
7
|
+
x,
|
|
8
|
+
y
|
|
32
9
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!b) return a;
|
|
37
|
-
return createPoint(a.x - b.x, a.y - b.y);
|
|
10
|
+
const subtractPoints = (a, b) => {
|
|
11
|
+
if (!b) return a;
|
|
12
|
+
return createPoint(a.x - b.x, a.y - b.y);
|
|
38
13
|
};
|
|
39
|
-
|
|
14
|
+
const addPoints = (a, b) => createPoint(a.x + b.x, a.y + b.y);
|
|
40
15
|
function isPoint(v) {
|
|
41
|
-
|
|
16
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y");
|
|
42
17
|
}
|
|
43
18
|
function createRect(r) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
19
|
+
const { x, y, width, height } = r;
|
|
20
|
+
const midX = x + width / 2;
|
|
21
|
+
const midY = y + height / 2;
|
|
22
|
+
return {
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
minX: x,
|
|
28
|
+
minY: y,
|
|
29
|
+
maxX: x + width,
|
|
30
|
+
maxY: y + height,
|
|
31
|
+
midX,
|
|
32
|
+
midY,
|
|
33
|
+
center: createPoint(midX, midY)
|
|
34
|
+
};
|
|
60
35
|
}
|
|
61
36
|
function isRect(v) {
|
|
62
|
-
|
|
37
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y") && Reflect.has(v, "width") && Reflect.has(v, "height");
|
|
63
38
|
}
|
|
64
39
|
function getRectCenters(v) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
40
|
+
return {
|
|
41
|
+
top: createPoint(v.midX, v.minY),
|
|
42
|
+
right: createPoint(v.maxX, v.midY),
|
|
43
|
+
bottom: createPoint(v.midX, v.maxY),
|
|
44
|
+
left: createPoint(v.minX, v.midY)
|
|
45
|
+
};
|
|
70
46
|
}
|
|
71
47
|
function getRectCorners(v) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
return {
|
|
49
|
+
top: createPoint(v.minX, v.minY),
|
|
50
|
+
right: createPoint(v.maxX, v.minY),
|
|
51
|
+
bottom: createPoint(v.maxX, v.maxY),
|
|
52
|
+
left: createPoint(v.minX, v.maxY)
|
|
53
|
+
};
|
|
77
54
|
}
|
|
78
55
|
function getRectEdges(v) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
const c = getRectCorners(v);
|
|
57
|
+
return {
|
|
58
|
+
top: [c.top, c.right],
|
|
59
|
+
right: [c.right, c.bottom],
|
|
60
|
+
bottom: [c.left, c.bottom],
|
|
61
|
+
left: [c.top, c.left]
|
|
62
|
+
};
|
|
85
63
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
isRect,
|
|
96
|
-
subtractPoints
|
|
97
|
-
});
|
|
64
|
+
exports.addPoints = addPoints;
|
|
65
|
+
exports.createPoint = createPoint;
|
|
66
|
+
exports.createRect = createRect;
|
|
67
|
+
exports.getRectCenters = getRectCenters;
|
|
68
|
+
exports.getRectCorners = getRectCorners;
|
|
69
|
+
exports.getRectEdges = getRectEdges;
|
|
70
|
+
exports.isPoint = isPoint;
|
|
71
|
+
exports.isRect = isRect;
|
|
72
|
+
exports.subtractPoints = subtractPoints;
|
package/dist/rect.mjs
CHANGED
|
@@ -1,66 +1,60 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/rect.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const createPoint = (x, y) => ({
|
|
3
|
+
x,
|
|
4
|
+
y
|
|
5
|
+
});
|
|
6
|
+
const subtractPoints = (a, b) => {
|
|
7
|
+
if (!b) return a;
|
|
8
|
+
return createPoint(a.x - b.x, a.y - b.y);
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
const addPoints = (a, b) => createPoint(a.x + b.x, a.y + b.y);
|
|
10
11
|
function isPoint(v) {
|
|
11
|
-
|
|
12
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y");
|
|
12
13
|
}
|
|
13
14
|
function createRect(r) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
const { x, y, width, height } = r;
|
|
16
|
+
const midX = x + width / 2;
|
|
17
|
+
const midY = y + height / 2;
|
|
18
|
+
return {
|
|
19
|
+
x,
|
|
20
|
+
y,
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
minX: x,
|
|
24
|
+
minY: y,
|
|
25
|
+
maxX: x + width,
|
|
26
|
+
maxY: y + height,
|
|
27
|
+
midX,
|
|
28
|
+
midY,
|
|
29
|
+
center: createPoint(midX, midY)
|
|
30
|
+
};
|
|
30
31
|
}
|
|
31
32
|
function isRect(v) {
|
|
32
|
-
|
|
33
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y") && Reflect.has(v, "width") && Reflect.has(v, "height");
|
|
33
34
|
}
|
|
34
35
|
function getRectCenters(v) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
return {
|
|
37
|
+
top: createPoint(v.midX, v.minY),
|
|
38
|
+
right: createPoint(v.maxX, v.midY),
|
|
39
|
+
bottom: createPoint(v.midX, v.maxY),
|
|
40
|
+
left: createPoint(v.minX, v.midY)
|
|
41
|
+
};
|
|
40
42
|
}
|
|
41
43
|
function getRectCorners(v) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
return {
|
|
45
|
+
top: createPoint(v.minX, v.minY),
|
|
46
|
+
right: createPoint(v.maxX, v.minY),
|
|
47
|
+
bottom: createPoint(v.maxX, v.maxY),
|
|
48
|
+
left: createPoint(v.minX, v.maxY)
|
|
49
|
+
};
|
|
47
50
|
}
|
|
48
51
|
function getRectEdges(v) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const c = getRectCorners(v);
|
|
53
|
+
return {
|
|
54
|
+
top: [c.top, c.right],
|
|
55
|
+
right: [c.right, c.bottom],
|
|
56
|
+
bottom: [c.left, c.bottom],
|
|
57
|
+
left: [c.top, c.left]
|
|
58
|
+
};
|
|
55
59
|
}
|
|
56
|
-
export {
|
|
57
|
-
addPoints,
|
|
58
|
-
createPoint,
|
|
59
|
-
createRect,
|
|
60
|
-
getRectCenters,
|
|
61
|
-
getRectCorners,
|
|
62
|
-
getRectEdges,
|
|
63
|
-
isPoint,
|
|
64
|
-
isRect,
|
|
65
|
-
subtractPoints
|
|
66
|
-
};
|
|
60
|
+
export { addPoints, createPoint, createRect, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, subtractPoints };
|
package/dist/resize.d.mts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { CompassDirection } from
|
|
2
|
-
import { Rect,
|
|
3
|
-
|
|
4
|
-
declare function resizeRect(rect: Rect, offset: Point, direction: CompassDirection, opts: ScalingOptions): RectInit;
|
|
5
|
-
|
|
6
|
-
export { resizeRect };
|
|
1
|
+
import { CompassDirection } from "./compass.mjs";
|
|
2
|
+
import { Point, Rect, RectInit, ScalingOptions } from "./types.mjs";
|
|
3
|
+
export declare function resizeRect(rect: Rect, offset: Point, direction: CompassDirection, opts: ScalingOptions): RectInit;
|
package/dist/resize.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { CompassDirection } from
|
|
2
|
-
import { Rect,
|
|
3
|
-
|
|
4
|
-
declare function resizeRect(rect: Rect, offset: Point, direction: CompassDirection, opts: ScalingOptions): RectInit;
|
|
5
|
-
|
|
6
|
-
export { resizeRect };
|
|
1
|
+
import { CompassDirection } from "./compass.js";
|
|
2
|
+
import { Point, Rect, RectInit, ScalingOptions } from "./types.js";
|
|
3
|
+
export declare function resizeRect(rect: Rect, offset: Point, direction: CompassDirection, opts: ScalingOptions): RectInit;
|
package/dist/resize.js
CHANGED
|
@@ -1,113 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/resize.ts
|
|
21
|
-
var resize_exports = {};
|
|
22
|
-
__export(resize_exports, {
|
|
23
|
-
resizeRect: () => resizeRect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
const require_affine_transform = require("./affine-transform.js");
|
|
6
|
+
const require_compass = require("./compass.js");
|
|
7
|
+
// src/resize.ts
|
|
8
|
+
const { sign, abs, min } = Math;
|
|
29
9
|
function getRectExtentPoint(rect, direction) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
const { minX, minY, maxX, maxY, midX, midY } = rect;
|
|
11
|
+
return {
|
|
12
|
+
x: direction.includes("w") ? minX : direction.includes("e") ? maxX : midX,
|
|
13
|
+
y: direction.includes("n") ? minY : direction.includes("s") ? maxY : midY
|
|
14
|
+
};
|
|
34
15
|
}
|
|
35
16
|
function getOppositeDirection(direction) {
|
|
36
|
-
|
|
17
|
+
return require_compass.oppositeDirectionMap[direction];
|
|
37
18
|
}
|
|
38
19
|
function resizeRect(rect, offset, direction, opts) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return transformRect(
|
|
80
|
-
rect,
|
|
81
|
-
import_affine_transform.AffineTransform.scale(scale.x, scale.y, {
|
|
82
|
-
x: rect.midX,
|
|
83
|
-
y: rect.midY
|
|
84
|
-
}),
|
|
85
|
-
false
|
|
86
|
-
);
|
|
87
|
-
}
|
|
20
|
+
const { scalingOriginMode, lockAspectRatio } = opts;
|
|
21
|
+
const extent = getRectExtentPoint(rect, direction);
|
|
22
|
+
const oppositeExtent = getRectExtentPoint(rect, getOppositeDirection(direction));
|
|
23
|
+
if (scalingOriginMode === "center") offset = {
|
|
24
|
+
x: offset.x * 2,
|
|
25
|
+
y: offset.y * 2
|
|
26
|
+
};
|
|
27
|
+
const newExtent = {
|
|
28
|
+
x: extent.x + offset.x,
|
|
29
|
+
y: extent.y + offset.y
|
|
30
|
+
};
|
|
31
|
+
const multiplier = {
|
|
32
|
+
x: require_compass.compassDirectionMap[direction].x * 2 - 1,
|
|
33
|
+
y: require_compass.compassDirectionMap[direction].y * 2 - 1
|
|
34
|
+
};
|
|
35
|
+
const newSize = {
|
|
36
|
+
width: newExtent.x - oppositeExtent.x,
|
|
37
|
+
height: newExtent.y - oppositeExtent.y
|
|
38
|
+
};
|
|
39
|
+
const scaleX = multiplier.x * newSize.width / rect.width;
|
|
40
|
+
const scaleY = multiplier.y * newSize.height / rect.height;
|
|
41
|
+
const largestMagnitude = abs(scaleX) > abs(scaleY) ? scaleX : scaleY;
|
|
42
|
+
const scale = lockAspectRatio ? {
|
|
43
|
+
x: largestMagnitude,
|
|
44
|
+
y: largestMagnitude
|
|
45
|
+
} : {
|
|
46
|
+
x: extent.x === oppositeExtent.x ? 1 : scaleX,
|
|
47
|
+
y: extent.y === oppositeExtent.y ? 1 : scaleY
|
|
48
|
+
};
|
|
49
|
+
if (extent.y === oppositeExtent.y) scale.y = abs(scale.y);
|
|
50
|
+
else if (sign(scale.y) !== sign(scaleY)) scale.y *= -1;
|
|
51
|
+
if (extent.x === oppositeExtent.x) scale.x = abs(scale.x);
|
|
52
|
+
else if (sign(scale.x) !== sign(scaleX)) scale.x *= -1;
|
|
53
|
+
switch (scalingOriginMode) {
|
|
54
|
+
case "extent": return transformRect(rect, require_affine_transform.AffineTransform.scale(scale.x, scale.y, oppositeExtent), false);
|
|
55
|
+
case "center": return transformRect(rect, require_affine_transform.AffineTransform.scale(scale.x, scale.y, {
|
|
56
|
+
x: rect.midX,
|
|
57
|
+
y: rect.midY
|
|
58
|
+
}), false);
|
|
59
|
+
}
|
|
88
60
|
}
|
|
89
61
|
function createRectFromPoints(initialPoint, finalPoint, normalized = true) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
height: finalPoint.y - initialPoint.y
|
|
103
|
-
};
|
|
62
|
+
if (normalized) return {
|
|
63
|
+
x: min(finalPoint.x, initialPoint.x),
|
|
64
|
+
y: min(finalPoint.y, initialPoint.y),
|
|
65
|
+
width: abs(finalPoint.x - initialPoint.x),
|
|
66
|
+
height: abs(finalPoint.y - initialPoint.y)
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
x: initialPoint.x,
|
|
70
|
+
y: initialPoint.y,
|
|
71
|
+
width: finalPoint.x - initialPoint.x,
|
|
72
|
+
height: finalPoint.y - initialPoint.y
|
|
73
|
+
};
|
|
104
74
|
}
|
|
105
75
|
function transformRect(rect, transform, normalized = true) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
76
|
+
return createRectFromPoints(transform.applyTo({
|
|
77
|
+
x: rect.minX,
|
|
78
|
+
y: rect.minY
|
|
79
|
+
}), transform.applyTo({
|
|
80
|
+
x: rect.maxX,
|
|
81
|
+
y: rect.maxY
|
|
82
|
+
}), normalized);
|
|
109
83
|
}
|
|
110
|
-
|
|
111
|
-
0 && (module.exports = {
|
|
112
|
-
resizeRect
|
|
113
|
-
});
|
|
84
|
+
exports.resizeRect = resizeRect;
|