@leafer/display-module 1.0.0-beta.9 → 1.0.0-rc.10

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,28 +1,32 @@
1
1
  {
2
2
  "name": "@leafer/display-module",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "@leafer/display-module",
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",
13
16
  "url": "https://github.com/leaferjs/leafer.git"
14
17
  },
15
- "homepage": "https://github.com/leaferjs/leafer/tree/main/packages/display-module",
18
+ "homepage": "https://github.com/leaferjs/leafer/tree/main/packages/display-module/display-module",
16
19
  "bugs": "https://github.com/leaferjs/leafer/issues",
17
20
  "keywords": [
18
21
  "leafer",
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/event": "1.0.0-beta.9",
23
- "@leafer/math": "1.0.0-beta.9"
25
+ "@leafer/helper": "1.0.0-rc.10",
26
+ "@leafer/event": "1.0.0-rc.10",
27
+ "@leafer/math": "1.0.0-rc.10"
24
28
  },
25
29
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-beta.9"
30
+ "@leafer/interface": "1.0.0-rc.10"
27
31
  }
28
32
  }
@@ -1,6 +1,9 @@
1
- import { ILeaf, ILeaferCanvas, IRenderOptions, IBranchRenderModule } from '@leafer/interface'
1
+ import { LeafBoundsHelper } from '@leafer/helper'
2
+ import { ILeaferCanvas, IRenderOptions, IBranchRenderModule } from '@leafer/interface'
2
3
 
3
4
 
5
+ const { excludeRenderBounds } = LeafBoundsHelper
6
+
4
7
  export const BranchRender: IBranchRenderModule = {
5
8
 
6
9
  __updateChange(): void {
@@ -18,73 +21,52 @@ export const BranchRender: IBranchRenderModule = {
18
21
  if (this.__worldOpacity) {
19
22
 
20
23
  if (this.__.__single) {
21
- canvas.resetTransform()
22
- const tempCanvas = canvas.getSameCanvas()
24
+
25
+ const tempCanvas = canvas.getSameCanvas(false, true)
23
26
 
24
27
  this.__renderBranch(tempCanvas, options)
25
28
 
26
- canvas.opacity = this.__worldOpacity
29
+ const nowWorld = this.__getNowWorld(options)
30
+
31
+ canvas.opacity = this.__.opacity
32
+ canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true)
27
33
 
28
- const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode
29
- options.matrix ? canvas.copyWorld(tempCanvas, null, null, blendMode) : canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode)
34
+ tempCanvas.recycle(nowWorld)
30
35
 
31
- tempCanvas.recycle()
32
36
  } else {
37
+
33
38
  this.__renderBranch(canvas, options)
39
+
34
40
  }
35
41
 
36
42
  }
43
+
37
44
  },
38
45
 
39
46
  __renderBranch(canvas: ILeaferCanvas, options: IRenderOptions): void {
47
+ if (this.__hasMask) {
40
48
 
41
- let child: ILeaf
42
- const { children } = this
43
-
44
- if (this.__hasMask && children.length > 1) {
49
+ this.__renderMask(canvas, options)
45
50
 
46
- let mask: boolean
47
- let maskCanvas = canvas.getSameCanvas()
48
- let contentCanvas = canvas.getSameCanvas()
51
+ } else {
49
52
 
53
+ const { children } = this
50
54
  for (let i = 0, len = children.length; i < len; i++) {
51
- child = children[i]
52
-
53
- if (child.isMask) {
54
- if (mask) {
55
- this.__renderMask(canvas, contentCanvas, maskCanvas)
56
- maskCanvas.clear()
57
- contentCanvas.clear()
58
- } else {
59
- mask = true
60
- }
61
-
62
- child.__render(maskCanvas, options)
63
- continue
64
- }
65
-
66
- child.__render(contentCanvas, options)
55
+ if (excludeRenderBounds(children[i], options)) continue
56
+ children[i].__render(canvas, options)
67
57
  }
68
58
 
69
- this.__renderMask(canvas, contentCanvas, maskCanvas)
70
- maskCanvas.recycle()
71
- contentCanvas.recycle()
72
-
73
- } else {
59
+ }
60
+ },
74
61
 
75
- const { bounds, hideBounds } = options
76
62
 
63
+ __clip(canvas: ILeaferCanvas, options: IRenderOptions): void {
64
+ if (this.__worldOpacity) {
65
+ const { children } = this
77
66
  for (let i = 0, len = children.length; i < len; i++) {
78
- child = children[i]
79
-
80
- if (bounds && !bounds.hit(child.__world, options.matrix)) continue
81
- if (hideBounds && hideBounds.includes(child.__world, options.matrix)) continue
82
-
83
- child.__render(canvas, options)
67
+ if (excludeRenderBounds(children[i], options)) continue
68
+ children[i].__clip(canvas, options)
84
69
  }
85
-
86
70
  }
87
-
88
71
  }
89
-
90
72
  }
package/src/LeafBounds.ts CHANGED
@@ -1,120 +1,145 @@
1
1
  import { ILeafBoundsModule } from '@leafer/interface'
2
2
  import { BoundsHelper } from '@leafer/math'
3
+ import { BranchHelper, LeafHelper } from '@leafer/helper'
3
4
 
4
5
 
6
+ const { updateMatrix, updateAllMatrix, hasParentAutoLayout } = LeafHelper
7
+ const { updateBounds } = BranchHelper
5
8
  const { toOuterOf, copyAndSpread } = BoundsHelper
6
9
 
7
10
  export const LeafBounds: ILeafBoundsModule = {
8
11
 
9
12
  __updateWorldBounds(): void {
10
13
 
11
- if (this.__layout.boundsChanged) {
14
+ toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
12
15
 
13
- let resize: boolean
14
- const layout = this.__layout
16
+ if (this.__layout.resized) {
17
+ this.__onUpdateSize()
18
+ this.__layout.resized = false
19
+ }
15
20
 
21
+ },
16
22
 
17
- if (layout.boxChanged) {
23
+ __updateLocalBounds(): void {
18
24
 
19
- this.__updatePath()
20
- this.__updateRenderPath()
25
+ const layout = this.__layout
21
26
 
22
- this.__updateBoxBounds()
23
- layout.boxChanged = false
24
- resize = true
25
- }
27
+ if (layout.boxChanged) {
26
28
 
29
+ this.__updatePath()
30
+ this.__updateRenderPath()
27
31
 
28
- if (layout.localBoxChanged) { // position change
32
+ this.__updateBoxBounds()
33
+ layout.boxChanged = false
34
+ layout.resized = true
35
+ }
29
36
 
30
- this.__updateLocalBoxBounds()
31
- layout.localBoxChanged = false
32
37
 
33
- if (layout.strokeSpread) layout.strokeChanged = true
34
- if (layout.renderSpread) layout.renderChanged = true
35
- this.parent?.__layout.boxChange()
36
- }
38
+ if (layout.localBoxChanged) { // position change
37
39
 
40
+ if (this.__local) this.__updateLocalBoxBounds()
41
+ layout.localBoxChanged = false
38
42
 
39
- if (layout.strokeChanged) {
43
+ if (layout.strokeSpread) layout.strokeChanged = true
44
+ if (layout.renderSpread) layout.renderChanged = true
45
+ if (this.parent) this.parent.__layout.boxChange()
46
+ }
40
47
 
41
- layout.strokeSpread = this.__updateStrokeSpread()
42
48
 
43
- if (layout.strokeSpread) {
49
+ if (layout.strokeChanged) {
44
50
 
45
- if (layout.strokeBounds === layout.boxBounds) {
46
- layout.spreadStroke()
47
- }
51
+ layout.strokeSpread = this.__updateStrokeSpread()
48
52
 
49
- this.__updateStrokeBounds()
50
- this.__updateLocalStrokeBounds()
53
+ if (layout.strokeSpread) {
51
54
 
52
- } else {
53
- layout.spreadStrokeCancel()
55
+ if (layout.strokeBounds === layout.boxBounds) {
56
+ layout.spreadStroke()
54
57
  }
55
58
 
56
- layout.strokeChanged = false
57
- if (layout.renderSpread) layout.renderChanged = true
59
+ this.__updateStrokeBounds()
60
+ this.__updateLocalStrokeBounds()
58
61
 
59
- if (this.parent) this.parent.__layout.strokeChange()
60
- resize || (resize = true)
62
+ } else {
63
+ layout.spreadStrokeCancel()
61
64
  }
62
65
 
66
+ layout.strokeChanged = false
67
+ if (layout.renderSpread) layout.renderChanged = true
63
68
 
64
- if (layout.renderChanged) {
69
+ if (this.parent) this.parent.__layout.strokeChange()
70
+ layout.resized = true
71
+ }
65
72
 
66
- layout.renderSpread = this.__updateRenderSpread()
67
73
 
68
- if (layout.renderSpread) {
74
+ if (layout.renderChanged) {
69
75
 
70
- if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
71
- layout.spreadRender()
72
- }
76
+ layout.renderSpread = this.__updateRenderSpread()
73
77
 
74
- this.__updateRenderBounds()
75
- this.__updateLocalRenderBounds()
78
+ if (layout.renderSpread) {
76
79
 
77
- } else {
78
- layout.spreadRenderCancel()
80
+ if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
81
+ layout.spreadRender()
79
82
  }
80
83
 
81
- layout.renderChanged = false
84
+ this.__updateRenderBounds()
85
+ this.__updateLocalRenderBounds()
82
86
 
83
- if (this.parent) this.parent.__layout.renderChange()
87
+ } else {
88
+ layout.spreadRenderCancel()
84
89
  }
85
90
 
91
+ layout.renderChanged = false
86
92
 
87
- layout.boundsChanged = false
88
-
89
- toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
90
-
91
- if (resize) this.__onUpdateSize()
92
-
93
- } else {
94
- toOuterOf(this.__layout.renderBounds, this.__world, this.__world)
93
+ if (this.parent) this.parent.__layout.renderChange()
95
94
  }
96
95
 
96
+ layout.boundsChanged = false
97
+
97
98
  },
98
99
 
99
100
  __updateLocalBoxBounds(): void {
101
+ if (this.__hasAutoLayout) this.__updateAutoLayout()
100
102
  toOuterOf(this.__layout.boxBounds, this.__local, this.__local)
101
103
  },
102
104
 
103
105
  __updateLocalStrokeBounds(): void {
104
- toOuterOf(this.__layout.strokeBounds, this.__local, this.__layout.localStrokeBounds)
106
+ toOuterOf(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds)
105
107
  },
106
108
 
107
109
  __updateLocalRenderBounds(): void {
108
- toOuterOf(this.__layout.renderBounds, this.__local, this.__layout.localRenderBounds)
110
+ toOuterOf(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds)
109
111
  },
110
112
 
111
113
 
112
114
  __updateBoxBounds(): void {
113
115
  const b = this.__layout.boxBounds
116
+ const { width, height } = this.__
114
117
  b.x = 0
115
118
  b.y = 0
116
- b.width = this.__.width
117
- b.height = this.__.height
119
+ b.width = width
120
+ b.height = height
121
+ },
122
+
123
+
124
+ __updateAutoLayout(): void {
125
+ this.__layout.matrixChanged = true
126
+ if (this.isBranch) {
127
+ if (this.leafer) this.leafer.layouter.addExtra(this) // add part render
128
+ if (hasParentAutoLayout(this)) {
129
+ updateMatrix(this)
130
+ } else {
131
+ updateAllMatrix(this)
132
+ updateBounds(this, this)
133
+ }
134
+ } else {
135
+ updateMatrix(this)
136
+ }
137
+ },
138
+
139
+ __updateNaturalSize(): void {
140
+ const { __: data, __layout: layout } = this
141
+ data.__naturalWidth = layout.boxBounds.width
142
+ data.__naturalHeight = layout.boxBounds.height
118
143
  },
119
144
 
120
145
  __updateStrokeBounds(): void {
@@ -1,23 +1,35 @@
1
- import { ILeafDataProxyModule } from '@leafer/interface'
1
+ import { ILeafDataProxyModule, IObject, IValue } from '@leafer/interface'
2
2
  import { PropertyEvent } from '@leafer/event'
3
3
 
4
4
 
5
5
  export const LeafDataProxy: ILeafDataProxyModule = {
6
6
 
7
- __setAttr(name: string, newValue: unknown): void {
8
- if (this.leafer && this.leafer.ready) {
9
- this.__[name] = newValue
10
- const { CHANGE } = PropertyEvent
11
- const event = new PropertyEvent(CHANGE, this, name, this.__.__get(name), newValue)
12
- if (this.hasEvent(CHANGE) && !this.isLeafer) this.emitEvent(event)
13
- this.leafer.emitEvent(event)
7
+ __setAttr(name: string, newValue: IValue): void {
8
+ if (this.leafer && this.leafer.created) {
9
+ const oldValue = this.__.__getInput(name)
10
+ if (typeof newValue === 'object' || oldValue !== newValue) {
11
+ (this.__ as IObject)[name] = newValue
12
+ if (this.__proxyData) this.setProxyAttr(name, newValue)
13
+
14
+ const { CHANGE } = PropertyEvent
15
+ const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue)
16
+
17
+ if (this.isLeafer) {
18
+ this.emitEvent(new PropertyEvent(PropertyEvent.LEAFER_CHANGE, this, name, oldValue, newValue))
19
+ } else {
20
+ if (this.hasEvent(CHANGE)) this.emitEvent(event)
21
+ }
22
+
23
+ this.leafer.emitEvent(event)
24
+ }
14
25
  } else {
15
- this.__[name] = newValue
26
+ (this.__ as IObject)[name] = newValue
27
+ if (this.__proxyData) this.setProxyAttr(name, newValue)
16
28
  }
17
29
  },
18
30
 
19
- __getAttr(name: string): unknown {
31
+ __getAttr(name: string): IValue {
32
+ if (this.__proxyData) return this.getProxyAttr(name)
20
33
  return this.__.__get(name)
21
34
  }
22
-
23
35
  }
@@ -1,4 +1,5 @@
1
1
  import { IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId, IEvent, IObject, IEventTarget, ILeafEventerModule } from '@leafer/interface'
2
+ import { EventCreator } from '@leafer/platform'
2
3
 
3
4
  const empty = {}
4
5
 
@@ -55,15 +56,13 @@ export const LeafEventer: ILeafEventerModule = {
55
56
  on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId {
56
57
  if (bind) listener = listener.bind(bind)
57
58
  this.on(type, listener, options)
58
- return { type, listener, options }
59
+ return { type, current: this, listener, options }
59
60
  },
60
61
 
61
62
  off_(id: IEventListenerId | IEventListenerId[]): void {
62
63
  if (!id) return
63
64
  const list = id instanceof Array ? id : [id]
64
- list.forEach(item => {
65
- this.off(item.type, item.listener, item.options)
66
- })
65
+ list.forEach(item => item.current.off(item.type, item.listener, item.options))
67
66
  list.length = 0
68
67
  },
69
68
 
@@ -72,6 +71,8 @@ export const LeafEventer: ILeafEventerModule = {
72
71
  },
73
72
 
74
73
  emit(type: string, event?: IEvent | IObject, capture?: boolean): void {
74
+ if (!event && EventCreator.has(type)) event = EventCreator.get(type, { type, target: this, current: this } as IEvent)
75
+
75
76
  const map = __getListenerMap(this, capture)
76
77
  const list = map[type]
77
78
  if (list) {
@@ -95,11 +96,8 @@ export const LeafEventer: ILeafEventerModule = {
95
96
 
96
97
  hasEvent(type: string, capture?: boolean): boolean {
97
98
  const { __bubbleMap: b, __captureMap: c } = this
98
- if (capture === undefined) {
99
- return !!((c && c[type]) || (b && b[type]))
100
- } else {
101
- return !!(capture ? (c && c[type]) : (b && b[type]))
102
- }
99
+ const hasB = b && b[type], hasC = c && c[type]
100
+ return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB))
103
101
  },
104
102
 
105
103
  }
package/src/LeafMatrix.ts CHANGED
@@ -1,97 +1,45 @@
1
- import { ILeafMatrixModule } from '@leafer/interface'
2
- import { OneRadian, MatrixHelper } from '@leafer/math'
1
+ import { ILeafMatrixModule, ILayoutData } from '@leafer/interface'
2
+ import { AroundHelper, MatrixHelper } from '@leafer/math'
3
3
 
4
4
 
5
- const { defaultMatrix } = MatrixHelper
6
- const { sin, cos } = Math
5
+ const { setLayout, multiplyParent, translateInner, defaultWorld } = MatrixHelper
6
+ const { toPoint, tempPoint } = AroundHelper
7
7
 
8
8
  export const LeafMatrix: ILeafMatrixModule = {
9
9
 
10
10
  __updateWorldMatrix(): void {
11
11
 
12
- const pw = this.parent ? this.parent.__world : defaultMatrix
13
- const r = this.__local
14
- const w = this.__world
15
-
16
- if (this.__layout.matrixChanged) this.__updateLocalMatrix()
17
-
18
- if (this.__layout.affectScaleOrRotation) {
19
- w.a = r.a * pw.a + r.b * pw.c
20
- w.b = r.a * pw.b + r.b * pw.d
21
- w.c = r.c * pw.a + r.d * pw.c
22
- w.d = r.c * pw.b + r.d * pw.d
23
- w.e = r.e * pw.a + r.f * pw.c + pw.e
24
- w.f = r.e * pw.b + r.f * pw.d + pw.f
25
- } else {
26
- w.a = pw.a
27
- w.b = pw.b
28
- w.c = pw.c
29
- w.d = pw.d
30
- w.e = r.e * pw.a + r.f * pw.c + pw.e
31
- w.f = r.e * pw.b + r.f * pw.d + pw.f
32
- }
12
+ multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__ as ILayoutData)
13
+
33
14
  },
34
15
 
35
16
  __updateLocalMatrix(): void {
36
17
 
37
- const r = this.__local
38
- const layout = this.__layout
39
-
40
- if (layout.affectScaleOrRotation) {
18
+ if (this.__local) {
41
19
 
42
- const { scaleX, scaleY } = this.__
20
+ const layout = this.__layout, local = this.__local, data = this.__
43
21
 
44
- if (layout.affectRotation) {
22
+ if (layout.affectScaleOrRotation) {
45
23
 
46
24
  if (layout.scaleChanged || layout.rotationChanged) {
47
-
48
- let { rotation, skewX, skewY } = this.__
49
-
50
- if (rotation || skewX || skewY) {
51
-
52
- rotation *= OneRadian
53
- if (skewX) skewX *= OneRadian
54
- if (skewY) skewY *= OneRadian
55
-
56
- r.a = scaleX * cos(rotation + skewY)
57
- r.b = scaleX * sin(rotation + skewY)
58
- r.c = scaleY * -sin(rotation - skewX)
59
- r.d = scaleY * cos(rotation - skewX)
60
-
61
- } else {
62
-
63
- r.a = scaleX
64
- r.b = 0
65
- r.c = 0
66
- r.d = scaleY
67
-
68
- layout.affectRotation = false
69
- }
70
-
71
- layout.scaleChanged = false
72
- layout.rotationChanged = false
73
-
25
+ setLayout(local, data as ILayoutData, null, layout.affectRotation)
26
+ layout.scaleChanged = layout.rotationChanged = false
74
27
  }
75
28
 
76
- } else {
29
+ }
77
30
 
78
- if (layout.scaleChanged) {
79
- r.a = scaleX
80
- r.d = scaleY
81
- layout.scaleChanged = false
82
- }
31
+ local.e = data.x
32
+ local.f = data.y
83
33
 
34
+ if (data.around) {
35
+ toPoint(data.around, layout.boxBounds, tempPoint)
36
+ translateInner(local, -tempPoint.x, -tempPoint.y)
84
37
  }
85
38
 
86
39
  }
87
40
 
88
- if (layout.positionChanged) {
89
- r.e = this.__.x
90
- r.f = this.__.y
91
- layout.positionChanged = false
92
- }
93
-
94
41
  this.__layout.matrixChanged = false
42
+
95
43
  }
96
44
 
97
45
  }
package/src/LeafRender.ts CHANGED
@@ -5,25 +5,37 @@ export const LeafRender: ILeafRenderModule = {
5
5
 
6
6
  __render(canvas: ILeaferCanvas, options: IRenderOptions): void {
7
7
  if (this.__worldOpacity) {
8
- canvas.setWorld(this.__world, options.matrix)
9
- canvas.opacity = this.__worldOpacity
8
+
9
+ canvas.setWorld(this.__nowWorld = this.__getNowWorld(options))
10
+ canvas.opacity = this.__.opacity
10
11
 
11
12
  if (this.__.__single) {
12
- const tempCanvas = canvas.getSameCanvas(true)
13
13
 
14
+ const tempCanvas = canvas.getSameCanvas(true, true)
14
15
  this.__draw(tempCanvas, options)
15
16
 
16
- const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode
17
- if (options.matrix) {
18
- canvas.resetTransform()
19
- canvas.copyWorld(tempCanvas, null, null, blendMode)
17
+ if (this.__worldFlipped) {
18
+ canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, this.__.__blendMode, true)
20
19
  } else {
21
- canvas.copyWorldToInner(tempCanvas, this.__world, this.__layout.renderBounds, blendMode)
20
+ canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, this.__.__blendMode)
22
21
  }
23
- tempCanvas.recycle()
22
+
23
+ tempCanvas.recycle(this.__nowWorld)
24
+
24
25
  } else {
26
+
25
27
  this.__draw(canvas, options)
28
+
26
29
  }
30
+
31
+ }
32
+ },
33
+
34
+ __clip(canvas: ILeaferCanvas, options: IRenderOptions): void {
35
+ if (this.__worldOpacity) {
36
+ canvas.setWorld(this.__nowWorld = this.__getNowWorld(options))
37
+ this.__drawRenderPath(canvas)
38
+ this.__.windingRule ? canvas.clip(this.__.windingRule) : canvas.clip()
27
39
  }
28
40
  },
29
41
 
package/src/index.ts CHANGED
@@ -2,8 +2,6 @@ export { LeafEventer } from './LeafEventer'
2
2
  export { LeafDataProxy } from './LeafDataProxy'
3
3
  export { LeafMatrix } from './LeafMatrix'
4
4
  export { LeafBounds } from './LeafBounds'
5
- export { LeafHit } from './LeafHit'
6
5
  export { LeafRender } from './LeafRender'
7
- export { LeafMask } from './LeafMask'
8
6
 
9
7
  export { BranchRender } from './BranchRender'
@@ -0,0 +1,15 @@
1
+ import { ILeafEventerModule, ILeafDataProxyModule, ILeafMatrixModule, ILeafBoundsModule, ILeafRenderModule, IBranchRenderModule } from '@leafer/interface';
2
+
3
+ declare const LeafEventer: ILeafEventerModule;
4
+
5
+ declare const LeafDataProxy: ILeafDataProxyModule;
6
+
7
+ declare const LeafMatrix: ILeafMatrixModule;
8
+
9
+ declare const LeafBounds: ILeafBoundsModule;
10
+
11
+ declare const LeafRender: ILeafRenderModule;
12
+
13
+ declare const BranchRender: IBranchRenderModule;
14
+
15
+ export { BranchRender, LeafBounds, LeafDataProxy, LeafEventer, LeafMatrix, LeafRender };
package/src/LeafHit.ts DELETED
@@ -1,23 +0,0 @@
1
- import { ILeafHitModule, IRadiusPointData, ILeaferCanvas } from '@leafer/interface'
2
- import { PointHelper } from '@leafer/math'
3
-
4
-
5
- const { toInnerRadiusPointOf } = PointHelper
6
- const inner = {} as IRadiusPointData
7
-
8
- export const LeafHit: ILeafHitModule = {
9
-
10
- __hitWorld(point: IRadiusPointData): boolean {
11
- if (this.__layout.hitCanvasChanged) {
12
- this.__updateHitCanvas()
13
- this.__layout.hitCanvasChanged = false
14
- }
15
- toInnerRadiusPointOf(point, this.__world, inner)
16
- return this.__hit(inner)
17
- },
18
-
19
- __drawHitPath(canvas: ILeaferCanvas): void {
20
- this.__drawRenderPath(canvas)
21
- }
22
-
23
- }
package/src/LeafMask.ts DELETED
@@ -1,38 +0,0 @@
1
- import { ILeaf, ILeaferCanvas, ILeafMaskModule } from '@leafer/interface'
2
-
3
-
4
- export const LeafMask: ILeafMaskModule = {
5
-
6
- __updateEraser(value?: boolean): void {
7
- this.__hasEraser = value ? true : this.children.some(item => item.__.isEraser)
8
- },
9
-
10
- __updateMask(value?: boolean): void {
11
- this.__hasMask = value ? true : this.children.some(item => item.__.isMask)
12
- },
13
-
14
- __renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void {
15
- content.resetTransform()
16
- content.useMask(mask)
17
- canvas.resetTransform()
18
- canvas.opacity = this.__worldOpacity
19
- canvas.copyWorld(content)
20
- },
21
-
22
- __removeMask(child?: ILeaf): void {
23
- if (child) {
24
- child.isMask = false
25
- this.remove(child)
26
- } else {
27
- const { children } = this
28
- for (let i = 0, len = children.length; i < len; i++) {
29
- child = children[i]
30
- if (child.isMask) {
31
- this.__removeMask(child)
32
- len--, i--
33
- }
34
- }
35
- }
36
- }
37
-
38
- }