@leafer/display-module 1.0.0-alpha.21 → 1.0.0-alpha.23
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 +4 -4
- package/src/LeafBounds.ts +26 -26
- package/src/LeafDataProxy.ts +15 -13
- package/src/LeafHit.ts +14 -10
- package/src/LeafMatrix.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display-module",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"description": "@leafer/display-module",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/event": "1.0.0-alpha.
|
|
23
|
-
"@leafer/math": "1.0.0-alpha.
|
|
22
|
+
"@leafer/event": "1.0.0-alpha.23",
|
|
23
|
+
"@leafer/math": "1.0.0-alpha.23"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
26
|
+
"@leafer/interface": "1.0.0-alpha.23"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/LeafBounds.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ILeafBoundsModule } from '@leafer/interface'
|
|
|
2
2
|
import { BoundsHelper } from '@leafer/math'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { toOuterOf, copyAndSpread } = BoundsHelper
|
|
6
6
|
|
|
7
7
|
export const LeafBounds: ILeafBoundsModule = {
|
|
8
8
|
|
|
@@ -27,36 +27,36 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
27
27
|
|
|
28
28
|
if (layout.localBoxBoundsChanged) { // position change
|
|
29
29
|
|
|
30
|
-
this.
|
|
30
|
+
this.__updateLocalBoxBounds()
|
|
31
31
|
layout.localBoxBoundsChanged = false
|
|
32
32
|
|
|
33
|
-
if (layout.
|
|
33
|
+
if (layout.strokeBoundsSpreadWidth) layout.strokeBoundsChanged = true
|
|
34
34
|
if (layout.renderBoundsSpreadWidth) layout.renderBoundsChanged = true
|
|
35
35
|
this.parent?.__layout.boxBoundsChange()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
if (layout.
|
|
39
|
+
if (layout.strokeBoundsChanged) {
|
|
40
40
|
|
|
41
|
-
layout.
|
|
41
|
+
layout.strokeBoundsSpreadWidth = this.__updateStrokeBoundsSpreadWidth()
|
|
42
42
|
|
|
43
|
-
if (layout.
|
|
43
|
+
if (layout.strokeBoundsSpreadWidth) {
|
|
44
44
|
|
|
45
|
-
if (layout.
|
|
46
|
-
layout.
|
|
45
|
+
if (layout.strokeBounds === layout.boxBounds) {
|
|
46
|
+
layout.strokeBoundsSpread()
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
layout.
|
|
49
|
+
this.__updateStrokeBounds()
|
|
50
|
+
this.__updateLocalStrokeBounds()
|
|
51
|
+
layout.strokeBoundsChanged = false
|
|
52
52
|
|
|
53
53
|
if (layout.renderBoundsSpreadWidth) layout.renderBoundsChanged = true
|
|
54
54
|
|
|
55
55
|
} else {
|
|
56
|
-
layout.
|
|
56
|
+
layout.strokeBoundsSpreadCancel()
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
this.parent?.__layout.
|
|
59
|
+
this.parent?.__layout.strokeBoundsChange()
|
|
60
60
|
resize || (resize = true)
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -67,12 +67,12 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
67
67
|
|
|
68
68
|
if (layout.renderBoundsSpreadWidth) {
|
|
69
69
|
|
|
70
|
-
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.
|
|
70
|
+
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
|
|
71
71
|
layout.renderBoundsSpread()
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
this.__updateRenderBounds()
|
|
75
|
-
this.
|
|
75
|
+
this.__updateLocalRenderBounds()
|
|
76
76
|
layout.renderBoundsChanged = false
|
|
77
77
|
|
|
78
78
|
} else {
|
|
@@ -85,26 +85,26 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
85
85
|
|
|
86
86
|
layout.boundsChanged = false
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
|
|
89
89
|
|
|
90
90
|
if (resize) this.__onUpdateSize()
|
|
91
91
|
|
|
92
92
|
} else {
|
|
93
|
-
|
|
93
|
+
toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
},
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
__updateLocalBoxBounds(): void {
|
|
99
|
+
toOuterOf(this.__layout.boxBounds, this.__local, this.__local)
|
|
100
100
|
},
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
__updateLocalStrokeBounds(): void {
|
|
103
|
+
toOuterOf(this.__layout.strokeBounds, this.__local, this.__layout.localStrokeBounds)
|
|
104
104
|
},
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
__updateLocalRenderBounds(): void {
|
|
107
|
+
toOuterOf(this.__layout.renderBounds, this.__local, this.__layout.localRenderBounds)
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
|
|
@@ -116,12 +116,12 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
116
116
|
b.height = this.__.height
|
|
117
117
|
},
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
copyAndSpread(this.__layout.
|
|
119
|
+
__updateStrokeBounds(): void {
|
|
120
|
+
copyAndSpread(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeBoundsSpreadWidth)
|
|
121
121
|
},
|
|
122
122
|
|
|
123
123
|
__updateRenderBounds(): void {
|
|
124
|
-
copyAndSpread(this.__layout.renderBounds, this.__layout.
|
|
124
|
+
copyAndSpread(this.__layout.renderBounds, this.__layout.strokeBounds, this.__layout.renderBoundsSpreadWidth)
|
|
125
125
|
},
|
|
126
126
|
|
|
127
127
|
}
|
package/src/LeafDataProxy.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { ILeafDataProxyModule } from '@leafer/interface'
|
|
2
|
-
import {
|
|
2
|
+
import { PropertyEvent } from '@leafer/event'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const LeafDataProxy: ILeafDataProxyModule = {
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
if (this.
|
|
9
|
-
const oldValue = this.__.
|
|
7
|
+
__setAttr(name: string, newValue: unknown): void {
|
|
8
|
+
if (this.leafer && this.leafer.ready) {
|
|
9
|
+
const oldValue = this.__.__get(name)
|
|
10
10
|
if (oldValue !== newValue) {
|
|
11
|
-
this.__[
|
|
12
|
-
this.
|
|
11
|
+
this.__[name] = newValue
|
|
12
|
+
this.leafer.emitEvent(new PropertyEvent(PropertyEvent.CHANGE, this, name, oldValue, newValue))
|
|
13
13
|
}
|
|
14
14
|
} else {
|
|
15
|
-
this.__[
|
|
15
|
+
this.__[name] = newValue
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
return this.__.
|
|
19
|
+
__getAttr(name: string): unknown {
|
|
20
|
+
return this.__.__get(name)
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
__updateAttr(
|
|
24
|
-
if (this.
|
|
25
|
-
|
|
26
|
-
this.
|
|
23
|
+
__updateAttr(name?: string): void {
|
|
24
|
+
if (this.leafer && this.leafer.ready) {
|
|
25
|
+
if (!name) name = 'fill'
|
|
26
|
+
const value = this.__.__get(name);
|
|
27
|
+
(this as any)[name] = value
|
|
28
|
+
this.leafer.emitEvent(new PropertyEvent(PropertyEvent.CHANGE, this, name, value, value))
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
package/src/LeafHit.ts
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { ILeafHitModule, IRadiusPointData } from '@leafer/interface'
|
|
1
|
+
import { ILeafHitModule, IRadiusPointData, ILeaferCanvas } from '@leafer/interface'
|
|
2
2
|
import { PointHelper } from '@leafer/math'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
const
|
|
5
|
+
const { toInnerRadiusPointOf } = PointHelper
|
|
6
|
+
const inner = {} as IRadiusPointData
|
|
7
7
|
|
|
8
8
|
export const LeafHit: ILeafHitModule = {
|
|
9
9
|
|
|
10
|
-
__updateHitCanvas(): void {
|
|
11
|
-
if (!this.__hitCanvas) this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this)
|
|
12
|
-
this.__drawRenderPath(this.__hitCanvas)
|
|
13
|
-
},
|
|
14
|
-
|
|
15
10
|
__hitWorld(point: IRadiusPointData): boolean {
|
|
16
11
|
if (this.__layout.hitCanvasChanged) {
|
|
17
12
|
this.__updateHitCanvas()
|
|
18
13
|
this.__layout.hitCanvasChanged = false
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
return this.__hit(
|
|
15
|
+
toInnerRadiusPointOf(point, this.__world, inner)
|
|
16
|
+
return this.__hit(inner)
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
__updateHitCanvas(): void {
|
|
20
|
+
if (!this.__hitCanvas) this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this)
|
|
21
|
+
this.__drawHitPath(this.__hitCanvas)
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
__drawHitPath(canvas: ILeaferCanvas): void {
|
|
25
|
+
this.__drawRenderPath(canvas)
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
}
|
package/src/LeafMatrix.ts
CHANGED
|
@@ -10,10 +10,10 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
10
10
|
__updateWorldMatrix(): void {
|
|
11
11
|
|
|
12
12
|
const pw = this.parent ? this.parent.__world : defaultMatrix
|
|
13
|
-
const r = this.
|
|
13
|
+
const r = this.__local
|
|
14
14
|
const w = this.__world
|
|
15
15
|
|
|
16
|
-
if (this.__layout.matrixChanged) this.
|
|
16
|
+
if (this.__layout.matrixChanged) this.__updateLocalMatrix()
|
|
17
17
|
|
|
18
18
|
if (this.__layout.affectScaleOrRotation) {
|
|
19
19
|
w.a = r.a * pw.a + r.b * pw.c
|
|
@@ -32,9 +32,9 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
__updateLocalMatrix(): void {
|
|
36
36
|
|
|
37
|
-
const r = this.
|
|
37
|
+
const r = this.__local
|
|
38
38
|
const layout = this.__layout
|
|
39
39
|
|
|
40
40
|
if (layout.affectScaleOrRotation) {
|