@leafer/display-module 1.0.0-rc.1 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display-module",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "@leafer/display-module",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -15,17 +15,18 @@
15
15
  "type": "git",
16
16
  "url": "https://github.com/leaferjs/leafer.git"
17
17
  },
18
- "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",
19
19
  "bugs": "https://github.com/leaferjs/leafer/issues",
20
20
  "keywords": [
21
21
  "leafer",
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/event": "1.0.0-rc.1",
26
- "@leafer/math": "1.0.0-rc.1"
25
+ "@leafer/helper": "1.0.0-rc.10",
26
+ "@leafer/event": "1.0.0-rc.10",
27
+ "@leafer/math": "1.0.0-rc.10"
27
28
  },
28
29
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.1"
30
+ "@leafer/interface": "1.0.0-rc.10"
30
31
  }
31
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,111 +1,113 @@
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
 
@@ -118,15 +120,26 @@ export const LeafBounds: ILeafBoundsModule = {
118
120
  b.height = height
119
121
  },
120
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
+
121
139
  __updateNaturalSize(): void {
122
140
  const { __: data, __layout: layout } = this
123
141
  data.__naturalWidth = layout.boxBounds.width
124
142
  data.__naturalHeight = layout.boxBounds.height
125
-
126
- if (this.around) {
127
- layout.positionChanged = layout.matrixChanged = true
128
- this.__updateWorldMatrix()
129
- }
130
143
  },
131
144
 
132
145
  __updateStrokeBounds(): void {
@@ -1,25 +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 {
7
+ __setAttr(name: string, newValue: IValue): void {
8
8
  if (this.leafer && this.leafer.created) {
9
- if (typeof newValue === 'object' || this.__.__getInput(name) !== newValue) {
10
- this.__[name] = newValue
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
+
11
14
  const { CHANGE } = PropertyEvent
12
- const event = new PropertyEvent(CHANGE, this, name, this.__.__get(name), newValue)
13
- if (this.hasEvent(CHANGE) && !this.isLeafer) this.emitEvent(event)
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
+
14
23
  this.leafer.emitEvent(event)
15
24
  }
16
25
  } else {
17
- this.__[name] = newValue
26
+ (this.__ as IObject)[name] = newValue
27
+ if (this.__proxyData) this.setProxyAttr(name, newValue)
18
28
  }
19
29
  },
20
30
 
21
- __getAttr(name: string): unknown {
31
+ __getAttr(name: string): IValue {
32
+ if (this.__proxyData) return this.getProxyAttr(name)
22
33
  return this.__.__get(name)
23
34
  }
24
-
25
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,13 +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 => this.off(item.type, item.listener, item.options))
65
+ list.forEach(item => item.current.off(item.type, item.listener, item.options))
65
66
  list.length = 0
66
67
  },
67
68
 
@@ -70,6 +71,8 @@ export const LeafEventer: ILeafEventerModule = {
70
71
  },
71
72
 
72
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
+
73
76
  const map = __getListenerMap(this, capture)
74
77
  const list = map[type]
75
78
  if (list) {
@@ -93,11 +96,8 @@ export const LeafEventer: ILeafEventerModule = {
93
96
 
94
97
  hasEvent(type: string, capture?: boolean): boolean {
95
98
  const { __bubbleMap: b, __captureMap: c } = this
96
- if (capture === undefined) {
97
- return !!((c && c[type]) || (b && b[type]))
98
- } else {
99
- return !!(capture ? (c && c[type]) : (b && b[type]))
100
- }
99
+ const hasB = b && b[type], hasC = c && c[type]
100
+ return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB))
101
101
  },
102
102
 
103
103
  }
package/src/LeafMatrix.ts CHANGED
@@ -1,122 +1,46 @@
1
- import { ILeafMatrixModule, IPointData } 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 { sin, cos } = Math
6
- const defaultWorld = { ...MatrixHelper.defaultMatrix, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 }
7
- const defaultCenter: IPointData = { x: 0.5, y: 0.5 }
5
+ const { setLayout, multiplyParent, translateInner, defaultWorld } = MatrixHelper
6
+ const { toPoint, tempPoint } = AroundHelper
8
7
 
9
8
  export const LeafMatrix: ILeafMatrixModule = {
10
9
 
11
10
  __updateWorldMatrix(): void {
12
11
 
13
- const pw = this.parent ? this.parent.__world : defaultWorld
14
- const r = this.__local
15
- const w = this.__world
16
-
17
- if (this.__layout.matrixChanged) this.__updateLocalMatrix()
18
-
19
- if (this.__layout.affectScaleOrRotation) {
20
- w.a = r.a * pw.a + r.b * pw.c
21
- w.b = r.a * pw.b + r.b * pw.d
22
- w.c = r.c * pw.a + r.d * pw.c
23
- w.d = r.c * pw.b + r.d * pw.d
24
- w.e = r.e * pw.a + r.f * pw.c + pw.e
25
- w.f = r.e * pw.b + r.f * pw.d + pw.f
26
-
27
- const data = this.__
28
- w.scaleX = pw.scaleX * data.scaleX
29
- w.scaleY = pw.scaleY * data.scaleY
30
-
31
- w.rotation = pw.rotation + data.rotation
32
- w.skewX = pw.skewX + data.skewX
33
- w.skewY = pw.skewY + data.skewY
34
- } else {
35
- w.a = pw.a
36
- w.b = pw.b
37
- w.c = pw.c
38
- w.d = pw.d
39
- w.e = r.e * pw.a + r.f * pw.c + pw.e
40
- w.f = r.e * pw.b + r.f * pw.d + pw.f
41
-
42
- w.scaleX = pw.scaleX
43
- w.scaleY = pw.scaleY
44
-
45
- w.rotation = pw.rotation
46
- w.skewX = pw.skewX
47
- w.skewY = pw.skewY
48
- }
12
+ multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__ as ILayoutData)
13
+
49
14
  },
50
15
 
51
16
  __updateLocalMatrix(): void {
52
17
 
53
- const r = this.__local
54
- const layout = this.__layout
55
-
56
- if (layout.affectScaleOrRotation) {
18
+ if (this.__local) {
57
19
 
58
- const { scaleX, scaleY } = this.__
20
+ const layout = this.__layout, local = this.__local, data = this.__
59
21
 
60
- if (layout.affectRotation) {
22
+ if (layout.affectScaleOrRotation) {
61
23
 
62
24
  if (layout.scaleChanged || layout.rotationChanged) {
63
-
64
- let { rotation, skewX, skewY } = this.__
65
-
66
- if (rotation || skewX || skewY) {
67
-
68
- rotation *= OneRadian
69
- if (skewX) skewX *= OneRadian
70
- if (skewY) skewY *= OneRadian
71
-
72
- r.a = scaleX * cos(rotation + skewY)
73
- r.b = scaleX * sin(rotation + skewY)
74
- r.c = scaleY * -sin(rotation - skewX)
75
- r.d = scaleY * cos(rotation - skewX)
76
-
77
- } else {
78
-
79
- r.a = scaleX
80
- r.b = 0
81
- r.c = 0
82
- r.d = scaleY
83
-
84
- layout.affectRotation = false
85
- }
86
-
87
- layout.scaleChanged = false
88
- layout.rotationChanged = false
89
-
90
- }
91
-
92
- } else {
93
-
94
- if (layout.scaleChanged) {
95
- r.a = scaleX
96
- r.d = scaleY
97
- layout.scaleChanged = false
25
+ setLayout(local, data as ILayoutData, null, layout.affectRotation)
26
+ layout.scaleChanged = layout.rotationChanged = false
98
27
  }
99
28
 
100
29
  }
101
30
 
102
- }
31
+ local.e = data.x
32
+ local.f = data.y
103
33
 
104
- if (layout.positionChanged) {
105
- r.e = this.__.x
106
- r.f = this.__.y
107
- const { width, height, around } = this.__
108
- if (around && width && height) {
109
- const origin = (around === 'center') ? defaultCenter : around
110
- const offsetX = width * origin.x, offsetY = height * origin.y
111
- r.e -= offsetX * r.a + offsetY * r.c
112
- r.f -= offsetX * r.b + offsetY * r.d
34
+ if (data.around) {
35
+ toPoint(data.around, layout.boxBounds, tempPoint)
36
+ translateInner(local, -tempPoint.x, -tempPoint.y)
113
37
  }
114
- layout.positionChanged = false
38
+
115
39
  }
116
40
 
117
41
  this.__layout.matrixChanged = false
118
- }
119
42
 
43
+ }
120
44
 
121
45
  }
122
46
 
package/src/LeafRender.ts CHANGED
@@ -5,24 +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 || this.__hasMirror) {
18
- canvas.copyWorldByReset(tempCanvas, null, null, blendMode)
17
+ if (this.__worldFlipped) {
18
+ canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, this.__.__blendMode, true)
19
19
  } else {
20
- canvas.copyWorldToInner(tempCanvas, this.__world, this.__layout.renderBounds, blendMode)
20
+ canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, this.__.__blendMode)
21
21
  }
22
- tempCanvas.recycle()
22
+
23
+ tempCanvas.recycle(this.__nowWorld)
24
+
23
25
  } else {
26
+
24
27
  this.__draw(canvas, options)
28
+
25
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()
26
39
  }
27
40
  },
28
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'
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeafEventerModule, ILeafDataProxyModule, ILeafMatrixModule, ILeafBoundsModule, ILeafHitModule, ILeafRenderModule, ILeafMaskModule, IBranchRenderModule } from '@leafer/interface';
1
+ import { ILeafEventerModule, ILeafDataProxyModule, ILeafMatrixModule, ILeafBoundsModule, ILeafRenderModule, IBranchRenderModule } from '@leafer/interface';
2
2
 
3
3
  declare const LeafEventer: ILeafEventerModule;
4
4
 
@@ -8,12 +8,8 @@ declare const LeafMatrix: ILeafMatrixModule;
8
8
 
9
9
  declare const LeafBounds: ILeafBoundsModule;
10
10
 
11
- declare const LeafHit: ILeafHitModule;
12
-
13
11
  declare const LeafRender: ILeafRenderModule;
14
12
 
15
- declare const LeafMask: ILeafMaskModule;
16
-
17
13
  declare const BranchRender: IBranchRenderModule;
18
14
 
19
- export { BranchRender, LeafBounds, LeafDataProxy, LeafEventer, LeafHit, LeafMask, LeafMatrix, LeafRender };
15
+ export { BranchRender, LeafBounds, LeafDataProxy, LeafEventer, LeafMatrix, LeafRender };
package/src/LeafHit.ts DELETED
@@ -1,29 +0,0 @@
1
- import { ILeafHitModule, IRadiusPointData, ILeaferCanvas } from '@leafer/interface'
2
- import { PointHelper } from '@leafer/math'
3
-
4
-
5
- const { toInnerRadiusPointOf, copy, setRadius } = PointHelper
6
- const inner = {} as IRadiusPointData
7
-
8
- export const LeafHit: ILeafHitModule = {
9
-
10
- __hitWorld(point: IRadiusPointData): boolean {
11
- if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
12
- this.__updateHitCanvas()
13
- this.__layout.hitCanvasChanged = false
14
- }
15
-
16
- if (this.__.hitRadius) {
17
- copy(inner, point), point = inner
18
- setRadius(point, this.__.hitRadius)
19
- }
20
-
21
- toInnerRadiusPointOf(point, this.__world, inner)
22
- return this.__hit(inner)
23
- },
24
-
25
- __drawHitPath(canvas: ILeaferCanvas): void {
26
- this.__drawRenderPath(canvas)
27
- }
28
-
29
- }
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
- }