@leafer/helper 1.0.0-alpha.7 → 1.0.0-alpha.9
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/package.json +3 -3
- package/src/LeafHelper.ts +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/helper",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"description": "@leafer/helper",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/math": "1.0.0-alpha.
|
|
22
|
+
"@leafer/math": "1.0.0-alpha.9"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
25
|
+
"@leafer/interface": "1.0.0-alpha.9"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/LeafHelper.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const LeafHelper = {
|
|
|
43
43
|
|
|
44
44
|
// transform
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
moveOfWorld(t: ILeaf, worldX: number, worldY: number): void {
|
|
47
47
|
const local = { x: worldX, y: worldY }
|
|
48
48
|
if (t.parent) MatrixHelper.toLocalPoint(t.parent.__world, local, local, true)
|
|
49
49
|
L.move(t, local.x, local.y)
|
|
@@ -54,17 +54,17 @@ export const LeafHelper = {
|
|
|
54
54
|
t.y = t.__.y + y
|
|
55
55
|
},
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
const local = t.parent ? PointHelper.tempToLocal(
|
|
57
|
+
zoomOfWorld(t: ILeaf, scale: number, worldCenter: IPointData, moveLayer?: ILeaf): void {
|
|
58
|
+
const local = t.parent ? PointHelper.tempToLocal(worldCenter, t.parent.__world) : worldCenter
|
|
59
59
|
this.zoom(t, scale, local, moveLayer)
|
|
60
60
|
},
|
|
61
61
|
|
|
62
|
-
zoom(t: ILeaf, scale: number,
|
|
62
|
+
zoom(t: ILeaf, scale: number, localCenter: IPointData, moveLayer?: ILeaf): void {
|
|
63
63
|
if (!moveLayer) moveLayer = t
|
|
64
64
|
const { x, y } = moveLayer.__
|
|
65
65
|
const { scaleX, scaleY } = t.__
|
|
66
|
-
const centerX =
|
|
67
|
-
const centerY =
|
|
66
|
+
const centerX = localCenter.x - x
|
|
67
|
+
const centerY = localCenter.y - y
|
|
68
68
|
const matrix = new Matrix().translate(centerX, centerY).scale(scale).translate(-centerX, -centerY)
|
|
69
69
|
moveLayer.x = x - matrix.e
|
|
70
70
|
moveLayer.y = y - matrix.f
|
|
@@ -72,17 +72,17 @@ export const LeafHelper = {
|
|
|
72
72
|
t.scaleY = scaleY * scale
|
|
73
73
|
},
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
const local = t.parent ? PointHelper.tempToLocal(
|
|
75
|
+
rotateOfWorld(t: ILeaf, angle: number, worldCenter: IPointData, moveLayer?: ILeaf): void {
|
|
76
|
+
const local = t.parent ? PointHelper.tempToLocal(worldCenter, t.parent.__world) : worldCenter
|
|
77
77
|
this.rotate(t, angle, local, moveLayer)
|
|
78
78
|
},
|
|
79
79
|
|
|
80
|
-
rotate(t: ILeaf, angle: number,
|
|
80
|
+
rotate(t: ILeaf, angle: number, localCenter: IPointData, moveLayer?: ILeaf): void {
|
|
81
81
|
if (!moveLayer) moveLayer = t
|
|
82
82
|
const { x, y } = moveLayer.__
|
|
83
83
|
const { rotation } = t.__
|
|
84
|
-
const centerX =
|
|
85
|
-
const centerY =
|
|
84
|
+
const centerX = localCenter.x - x
|
|
85
|
+
const centerY = localCenter.y - y
|
|
86
86
|
const matrix = new Matrix().translate(centerX, centerY).rotate(angle).translate(-centerX, -centerY)
|
|
87
87
|
moveLayer.x = x - matrix.e
|
|
88
88
|
moveLayer.y = y - matrix.f
|