@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display-module",
3
- "version": "1.0.0-alpha.21",
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.21",
23
- "@leafer/math": "1.0.0-alpha.21"
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.21"
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 { toWorld, copyAndSpread } = BoundsHelper
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.__updateRelativeBoxBounds()
30
+ this.__updateLocalBoxBounds()
31
31
  layout.localBoxBoundsChanged = false
32
32
 
33
- if (layout.eventBoundsSpreadWidth) layout.eventBoundsChanged = true
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.eventBoundsChanged) {
39
+ if (layout.strokeBoundsChanged) {
40
40
 
41
- layout.eventBoundsSpreadWidth = this.__updateEventBoundsSpreadWidth()
41
+ layout.strokeBoundsSpreadWidth = this.__updateStrokeBoundsSpreadWidth()
42
42
 
43
- if (layout.eventBoundsSpreadWidth) {
43
+ if (layout.strokeBoundsSpreadWidth) {
44
44
 
45
- if (layout.eventBounds === layout.boxBounds) {
46
- layout.eventBoundsSpread()
45
+ if (layout.strokeBounds === layout.boxBounds) {
46
+ layout.strokeBoundsSpread()
47
47
  }
48
48
 
49
- this.__updateEventBounds()
50
- this.__updateRelativeEventBounds()
51
- layout.eventBoundsChanged = false
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.eventBoundsSpreadCancel()
56
+ layout.strokeBoundsSpreadCancel()
57
57
  }
58
58
 
59
- this.parent?.__layout.eventBoundsChange()
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.eventBounds) {
70
+ if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
71
71
  layout.renderBoundsSpread()
72
72
  }
73
73
 
74
74
  this.__updateRenderBounds()
75
- this.__updateRelativeRenderBounds()
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
- toWorld(this.__layout.renderBounds, this.__world, this.__world)
88
+ toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
89
89
 
90
90
  if (resize) this.__onUpdateSize()
91
91
 
92
92
  } else {
93
- toWorld(this.__layout.renderBounds, this.__world, this.__world)
93
+ toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
94
94
  }
95
95
 
96
96
  },
97
97
 
98
- __updateRelativeBoxBounds(): void {
99
- toWorld(this.__layout.boxBounds, this.__relative, this.__relative)
98
+ __updateLocalBoxBounds(): void {
99
+ toOuterOf(this.__layout.boxBounds, this.__local, this.__local)
100
100
  },
101
101
 
102
- __updateRelativeEventBounds(): void {
103
- toWorld(this.__layout.eventBounds, this.__relative, this.__layout.relativeEventBounds)
102
+ __updateLocalStrokeBounds(): void {
103
+ toOuterOf(this.__layout.strokeBounds, this.__local, this.__layout.localStrokeBounds)
104
104
  },
105
105
 
106
- __updateRelativeRenderBounds(): void {
107
- toWorld(this.__layout.renderBounds, this.__relative, this.__layout.relativeRenderBounds)
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
- __updateEventBounds(): void {
120
- copyAndSpread(this.__layout.eventBounds, this.__layout.boxBounds, this.__layout.eventBoundsSpreadWidth)
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.eventBounds, this.__layout.renderBoundsSpreadWidth)
124
+ copyAndSpread(this.__layout.renderBounds, this.__layout.strokeBounds, this.__layout.renderBoundsSpreadWidth)
125
125
  },
126
126
 
127
127
  }
@@ -1,29 +1,31 @@
1
1
  import { ILeafDataProxyModule } from '@leafer/interface'
2
- import { AttrEvent } from '@leafer/event'
2
+ import { PropertyEvent } from '@leafer/event'
3
3
 
4
4
 
5
5
  export const LeafDataProxy: ILeafDataProxyModule = {
6
6
 
7
- __set(attrName: string, newValue: unknown): void {
8
- if (this.root) {
9
- const oldValue = this.__.__getInput(attrName)
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.__[attrName] = newValue
12
- this.root.emitEvent(new AttrEvent(AttrEvent.CHANGE, this, attrName, oldValue, newValue))
11
+ this.__[name] = newValue
12
+ this.leafer.emitEvent(new PropertyEvent(PropertyEvent.CHANGE, this, name, oldValue, newValue))
13
13
  }
14
14
  } else {
15
- this.__[attrName] = newValue
15
+ this.__[name] = newValue
16
16
  }
17
17
  },
18
18
 
19
- __get(attrName: string): unknown {
20
- return this.__.__getInput(attrName)
19
+ __getAttr(name: string): unknown {
20
+ return this.__.__get(name)
21
21
  },
22
22
 
23
- __updateAttr(attrName: string): void {
24
- if (this.root) {
25
- const value = this.__.__getInput(attrName)
26
- this.root.emitEvent(new AttrEvent(AttrEvent.CHANGE, this, attrName, value, value))
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 { toLocalRadiusPoint } = PointHelper
6
- const local = {} as IRadiusPointData
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
- toLocalRadiusPoint(point, this.__world, local)
21
- return this.__hit(local)
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.__relative
13
+ const r = this.__local
14
14
  const w = this.__world
15
15
 
16
- if (this.__layout.matrixChanged) this.__updateRelativeMatrix()
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
- __updateRelativeMatrix(): void {
35
+ __updateLocalMatrix(): void {
36
36
 
37
- const r = this.__relative
37
+ const r = this.__local
38
38
  const layout = this.__layout
39
39
 
40
40
  if (layout.affectScaleOrRotation) {