@leafer/helper 1.0.0-beta.12 → 1.0.0-beta.16

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 CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer/helper",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.16",
4
4
  "description": "@leafer/helper",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,9 +22,9 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/math": "1.0.0-beta.12"
25
+ "@leafer/math": "1.0.0-beta.16"
23
26
  },
24
27
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.12"
28
+ "@leafer/interface": "1.0.0-beta.16"
26
29
  }
27
30
  }
package/src/LeafHelper.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { IBranch, ILeaf, IMatrixData, IPointData } from '@leafer/interface'
2
- import { MatrixHelper, PointHelper } from '@leafer/math'
2
+ import { MathHelper, MatrixHelper, PointHelper } from '@leafer/math'
3
3
 
4
4
 
5
- const { copy, translate, toInnerPoint, scaleOfOuter, rotateOfOuter } = MatrixHelper
5
+ const { copy, translate, toInnerPoint, scaleOfOuter, rotateOfOuter, skewOfOuter } = MatrixHelper
6
6
  const matrix = {} as IMatrixData
7
7
 
8
8
  export const LeafHelper = {
@@ -97,7 +97,25 @@ export const LeafHelper = {
97
97
  if (!moveLayer) moveLayer = t
98
98
  moveLayer.x += matrix.e - t.__local.e
99
99
  moveLayer.y += matrix.f - t.__local.f
100
- t.rotation += angle
100
+ t.rotation = MathHelper.formatRotation(t.rotation + angle)
101
+
102
+ },
103
+
104
+ skewOfWorld(t: ILeaf, origin: IPointData, skewX: number, skewY?: number, moveLayer?: ILeaf): void {
105
+ t.__layout.checkUpdate()
106
+ const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin
107
+ this.skewOfLocal(t, local, skewX, skewY, moveLayer)
108
+ },
109
+
110
+ skewOfLocal(t: ILeaf, origin: IPointData, skewX: number, skewY: number, moveLayer?: ILeaf): void {
111
+ copy(matrix, t.__local)
112
+ if (moveLayer) translate(matrix, moveLayer.x, moveLayer.y)
113
+ skewOfOuter(matrix, origin, skewX, skewY)
114
+ if (!moveLayer) moveLayer = t
115
+ moveLayer.x = matrix.e - t.__local.e
116
+ moveLayer.y = matrix.f - t.__local.f
117
+ t.skewX = MathHelper.formatSkew(t.skewX + skewX)
118
+ t.skewY = MathHelper.formatSkew(t.skewY + skewY)
101
119
  },
102
120
 
103
121
  drop(t: ILeaf, parent: IBranch): void {
@@ -0,0 +1,44 @@
1
+ import { ILeaf, IPointData, IBranch, IBoundsData, IFunction } from '@leafer/interface';
2
+
3
+ declare const LeafHelper: {
4
+ updateAllWorldMatrix(leaf: ILeaf): void;
5
+ updateAllWorldOpacity(leaf: ILeaf): void;
6
+ updateAllChange(leaf: ILeaf): void;
7
+ worldHittable(t: ILeaf): boolean;
8
+ moveWorld(t: ILeaf, x: number, y: number): void;
9
+ moveLocal(t: ILeaf, x: number, y?: number): void;
10
+ zoomOfWorld(t: ILeaf, origin: IPointData, scaleX: number, scaleY?: number, moveLayer?: ILeaf): void;
11
+ zoomOfLocal(t: ILeaf, origin: IPointData, scaleX: number, scaleY?: number, moveLayer?: ILeaf): void;
12
+ rotateOfWorld(t: ILeaf, origin: IPointData, angle: number, moveLayer?: ILeaf): void;
13
+ rotateOfLocal(t: ILeaf, origin: IPointData, angle: number, moveLayer?: ILeaf): void;
14
+ skewOfWorld(t: ILeaf, origin: IPointData, skewX: number, skewY?: number, moveLayer?: ILeaf): void;
15
+ skewOfLocal(t: ILeaf, origin: IPointData, skewX: number, skewY: number, moveLayer?: ILeaf): void;
16
+ drop(t: ILeaf, parent: IBranch): void;
17
+ };
18
+
19
+ declare const LeafBoundsHelper: {
20
+ worldBounds(target: ILeaf): IBoundsData;
21
+ localBoxBounds(target: ILeaf): IBoundsData;
22
+ localEventBounds(target: ILeaf): IBoundsData;
23
+ localRenderBounds(target: ILeaf): IBoundsData;
24
+ maskLocalBoxBounds(target: ILeaf): IBoundsData;
25
+ maskLocalEventBounds(target: ILeaf): IBoundsData;
26
+ maskLocalRenderBounds(target: ILeaf): IBoundsData;
27
+ };
28
+
29
+ interface ILeafPushList {
30
+ push(item: ILeaf): void;
31
+ }
32
+ declare const BranchHelper: {
33
+ sort(a: ILeaf, b: ILeaf): number;
34
+ pushAllChildBranch(branch: ILeaf, pushList: ILeafPushList): void;
35
+ pushAllParent(leaf: ILeaf, pushList: ILeafPushList): void;
36
+ pushAllBranchStack(branch: ILeaf, pushList: ILeaf[]): void;
37
+ updateWorldBoundsByBranchStack(branchStack: ILeaf[]): void;
38
+ };
39
+
40
+ declare const WaitHelper: {
41
+ run(wait: IFunction[]): void;
42
+ };
43
+
44
+ export { BranchHelper, LeafBoundsHelper, LeafHelper, WaitHelper };