@leafer/display-module 1.0.0-rc.9 → 1.0.0
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 +7 -6
- package/src/BranchRender.ts +27 -44
- package/src/LeafBounds.ts +40 -23
- package/src/LeafDataProxy.ts +23 -2
- package/src/LeafEventer.ts +44 -20
- package/src/LeafMatrix.ts +7 -7
- package/src/LeafRender.ts +23 -8
- package/src/index.ts +0 -2
- package/types/index.d.ts +2 -6
- package/src/LeafHit.ts +0 -34
- package/src/LeafMask.ts +0 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display-module",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "@leafer/display-module",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,18 +15,19 @@
|
|
|
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/helper": "1.0.0
|
|
26
|
-
"@leafer/event": "1.0.0
|
|
27
|
-
"@leafer/math": "1.0.0
|
|
25
|
+
"@leafer/helper": "1.0.0",
|
|
26
|
+
"@leafer/event": "1.0.0",
|
|
27
|
+
"@leafer/math": "1.0.0",
|
|
28
|
+
"@leafer/debug": "1.0.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.0.0
|
|
31
|
+
"@leafer/interface": "1.0.0"
|
|
31
32
|
}
|
|
32
33
|
}
|
package/src/BranchRender.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
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,74 +21,54 @@ export const BranchRender: IBranchRenderModule = {
|
|
|
18
21
|
if (this.__worldOpacity) {
|
|
19
22
|
|
|
20
23
|
if (this.__.__single) {
|
|
21
|
-
|
|
24
|
+
|
|
25
|
+
if (this.__.eraser === 'path') return this.__renderEraser(canvas, options)
|
|
26
|
+
|
|
22
27
|
const tempCanvas = canvas.getSameCanvas(false, true)
|
|
23
28
|
|
|
24
29
|
this.__renderBranch(tempCanvas, options)
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
const nowWorld = this.__getNowWorld(options)
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
canvas.opacity = this.__.opacity
|
|
34
|
+
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true)
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
canvas.copyWorld(tempCanvas, null, null, blendMode)
|
|
32
|
-
} else {
|
|
33
|
-
canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode)
|
|
34
|
-
}
|
|
36
|
+
tempCanvas.recycle(nowWorld)
|
|
35
37
|
|
|
36
|
-
tempCanvas.recycle()
|
|
37
38
|
} else {
|
|
39
|
+
|
|
38
40
|
this.__renderBranch(canvas, options)
|
|
41
|
+
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
}
|
|
45
|
+
|
|
42
46
|
},
|
|
43
47
|
|
|
44
48
|
__renderBranch(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
49
|
+
if (this.__hasMask) {
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
const { children } = this
|
|
51
|
+
this.__renderMask(canvas, options)
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let mask: boolean
|
|
52
|
-
const maskCanvas = canvas.getSameCanvas(false, true)
|
|
53
|
-
const contentCanvas = canvas.getSameCanvas(false, true)
|
|
53
|
+
} else {
|
|
54
54
|
|
|
55
|
+
const { children } = this
|
|
55
56
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (child.isMask) {
|
|
59
|
-
if (mask) {
|
|
60
|
-
this.__renderMask(canvas, contentCanvas, maskCanvas)
|
|
61
|
-
} else {
|
|
62
|
-
mask = true
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
child.__render(maskCanvas, options)
|
|
66
|
-
continue
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
child.__render(mask ? contentCanvas : canvas, options)
|
|
57
|
+
if (excludeRenderBounds(children[i], options)) continue
|
|
58
|
+
children[i].__render(canvas, options)
|
|
70
59
|
}
|
|
71
60
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} else {
|
|
61
|
+
}
|
|
62
|
+
},
|
|
75
63
|
|
|
76
|
-
const { bounds, hideBounds } = options
|
|
77
64
|
|
|
65
|
+
__clip(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
66
|
+
if (this.__worldOpacity) {
|
|
67
|
+
const { children } = this
|
|
78
68
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (bounds && !bounds.hit(child.__world, options.matrix)) continue
|
|
82
|
-
if (hideBounds && hideBounds.includes(child.__world, options.matrix)) continue
|
|
83
|
-
|
|
84
|
-
child.__render(canvas, options)
|
|
69
|
+
if (excludeRenderBounds(children[i], options)) continue
|
|
70
|
+
children[i].__clip(canvas, options)
|
|
85
71
|
}
|
|
86
|
-
|
|
87
72
|
}
|
|
88
|
-
|
|
89
73
|
}
|
|
90
|
-
|
|
91
74
|
}
|
package/src/LeafBounds.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ILeafBoundsModule } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper } from '@leafer/math'
|
|
3
|
+
import { PathBounds } from '@leafer/path'
|
|
3
4
|
import { BranchHelper, LeafHelper } from '@leafer/helper'
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
const { updateMatrix, updateAllMatrix
|
|
7
|
+
const { updateMatrix, updateAllMatrix } = LeafHelper
|
|
7
8
|
const { updateBounds } = BranchHelper
|
|
8
|
-
const { toOuterOf, copyAndSpread } = BoundsHelper
|
|
9
|
+
const { toOuterOf, copyAndSpread, copy } = BoundsHelper
|
|
10
|
+
const { toBounds } = PathBounds
|
|
9
11
|
|
|
10
12
|
export const LeafBounds: ILeafBoundsModule = {
|
|
11
13
|
|
|
@@ -26,11 +28,10 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
26
28
|
|
|
27
29
|
if (layout.boxChanged) {
|
|
28
30
|
|
|
29
|
-
this.__updatePath()
|
|
31
|
+
if (!this.__.__pathInputed) this.__updatePath()
|
|
30
32
|
this.__updateRenderPath()
|
|
31
33
|
|
|
32
34
|
this.__updateBoxBounds()
|
|
33
|
-
layout.boxChanged = false
|
|
34
35
|
layout.resized = true
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -46,15 +47,16 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
|
|
50
|
+
layout.boxChanged = false // must after updateLocalBoxBounds()
|
|
51
|
+
|
|
52
|
+
|
|
49
53
|
if (layout.strokeChanged) {
|
|
50
54
|
|
|
51
55
|
layout.strokeSpread = this.__updateStrokeSpread()
|
|
52
56
|
|
|
53
57
|
if (layout.strokeSpread) {
|
|
54
58
|
|
|
55
|
-
if (layout.strokeBounds === layout.boxBounds)
|
|
56
|
-
layout.spreadStroke()
|
|
57
|
-
}
|
|
59
|
+
if (layout.strokeBounds === layout.boxBounds) layout.spreadStroke()
|
|
58
60
|
|
|
59
61
|
this.__updateStrokeBounds()
|
|
60
62
|
this.__updateLocalStrokeBounds()
|
|
@@ -64,7 +66,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
layout.strokeChanged = false
|
|
67
|
-
if (layout.renderSpread) layout.renderChanged = true
|
|
69
|
+
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true
|
|
68
70
|
|
|
69
71
|
if (this.parent) this.parent.__layout.strokeChange()
|
|
70
72
|
layout.resized = true
|
|
@@ -77,9 +79,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
77
79
|
|
|
78
80
|
if (layout.renderSpread) {
|
|
79
81
|
|
|
80
|
-
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds)
|
|
81
|
-
layout.spreadRender()
|
|
82
|
-
}
|
|
82
|
+
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) layout.spreadRender()
|
|
83
83
|
|
|
84
84
|
this.__updateRenderBounds()
|
|
85
85
|
this.__updateLocalRenderBounds()
|
|
@@ -98,7 +98,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
__updateLocalBoxBounds(): void {
|
|
101
|
-
if (this.__hasAutoLayout) this.__updateAutoLayout()
|
|
101
|
+
if (this.__hasAutoLayout) this.__updateAutoLayout() // origin / around / flow
|
|
102
102
|
toOuterOf(this.__layout.boxBounds, this.__local, this.__local)
|
|
103
103
|
},
|
|
104
104
|
|
|
@@ -113,24 +113,39 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
113
113
|
|
|
114
114
|
__updateBoxBounds(): void {
|
|
115
115
|
const b = this.__layout.boxBounds
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
const data = this.__
|
|
117
|
+
if (data.__pathInputed) {
|
|
118
|
+
toBounds(data.__pathForRender, b)
|
|
119
|
+
} else {
|
|
120
|
+
b.x = 0
|
|
121
|
+
b.y = 0
|
|
122
|
+
b.width = data.width
|
|
123
|
+
b.height = data.height
|
|
124
|
+
}
|
|
121
125
|
},
|
|
122
126
|
|
|
123
127
|
|
|
124
128
|
__updateAutoLayout(): void {
|
|
125
129
|
this.__layout.matrixChanged = true
|
|
126
130
|
if (this.isBranch) {
|
|
127
|
-
if (this.leafer) this.leafer.layouter.addExtra(this) // add part
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
if (this.leafer && this.leafer.ready) this.leafer.layouter.addExtra(this) // add part
|
|
132
|
+
|
|
133
|
+
if (this.__.flow) {
|
|
134
|
+
|
|
135
|
+
if (this.__layout.boxChanged) this.__updateFlowLayout()
|
|
136
|
+
|
|
137
|
+
updateAllMatrix(this)
|
|
138
|
+
updateBounds(this, this)
|
|
139
|
+
|
|
140
|
+
if (this.__.__autoSide) this.__updateBoxBounds()
|
|
141
|
+
|
|
130
142
|
} else {
|
|
143
|
+
|
|
131
144
|
updateAllMatrix(this)
|
|
132
145
|
updateBounds(this, this)
|
|
146
|
+
|
|
133
147
|
}
|
|
148
|
+
|
|
134
149
|
} else {
|
|
135
150
|
updateMatrix(this)
|
|
136
151
|
}
|
|
@@ -143,11 +158,13 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
143
158
|
},
|
|
144
159
|
|
|
145
160
|
__updateStrokeBounds(): void {
|
|
146
|
-
|
|
161
|
+
const layout = this.__layout
|
|
162
|
+
copyAndSpread(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread)
|
|
147
163
|
},
|
|
148
164
|
|
|
149
165
|
__updateRenderBounds(): void {
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
const layout = this.__layout
|
|
167
|
+
layout.renderSpread > 0 ? copyAndSpread(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy(layout.renderBounds, layout.strokeBounds) // Box use -1
|
|
168
|
+
}
|
|
152
169
|
|
|
153
170
|
}
|
package/src/LeafDataProxy.ts
CHANGED
|
@@ -1,24 +1,45 @@
|
|
|
1
1
|
import { ILeafDataProxyModule, IObject, IValue } from '@leafer/interface'
|
|
2
2
|
import { PropertyEvent } from '@leafer/event'
|
|
3
|
+
import { Debug } from '@leafer/debug'
|
|
3
4
|
|
|
4
5
|
|
|
6
|
+
const { isFinite } = Number
|
|
7
|
+
const debug = Debug.get('setAttr')
|
|
8
|
+
|
|
5
9
|
export const LeafDataProxy: ILeafDataProxyModule = {
|
|
6
10
|
|
|
7
|
-
__setAttr(name: string, newValue: IValue):
|
|
11
|
+
__setAttr(name: string, newValue: IValue, checkFiniteNumber?: boolean): boolean {
|
|
8
12
|
if (this.leafer && this.leafer.created) {
|
|
9
13
|
const oldValue = this.__.__getInput(name)
|
|
14
|
+
|
|
15
|
+
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) { // 警告 NaN、Infinity、-Infinity、null、非有效数字
|
|
16
|
+
debug.warn(this.innerName, name, newValue)
|
|
17
|
+
newValue = undefined // must
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
11
21
|
(this.__ as IObject)[name] = newValue
|
|
12
22
|
if (this.__proxyData) this.setProxyAttr(name, newValue)
|
|
13
23
|
|
|
14
24
|
const { CHANGE } = PropertyEvent
|
|
15
25
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue)
|
|
16
|
-
|
|
26
|
+
|
|
27
|
+
if (this.isLeafer) {
|
|
28
|
+
this.emitEvent(new PropertyEvent(PropertyEvent.LEAFER_CHANGE, this, name, oldValue, newValue))
|
|
29
|
+
} else {
|
|
30
|
+
if (this.hasEvent(CHANGE)) this.emitEvent(event)
|
|
31
|
+
}
|
|
32
|
+
|
|
17
33
|
this.leafer.emitEvent(event)
|
|
34
|
+
return true
|
|
35
|
+
} else {
|
|
36
|
+
return false
|
|
18
37
|
}
|
|
38
|
+
|
|
19
39
|
} else {
|
|
20
40
|
(this.__ as IObject)[name] = newValue
|
|
21
41
|
if (this.__proxyData) this.setProxyAttr(name, newValue)
|
|
42
|
+
return true
|
|
22
43
|
}
|
|
23
44
|
},
|
|
24
45
|
|
package/src/LeafEventer.ts
CHANGED
|
@@ -33,24 +33,47 @@ export const LeafEventer: ILeafEventerModule = {
|
|
|
33
33
|
})
|
|
34
34
|
},
|
|
35
35
|
|
|
36
|
-
off(type
|
|
37
|
-
|
|
38
|
-
if (options) capture = typeof options === 'boolean' ? options : options.capture
|
|
36
|
+
off(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void {
|
|
37
|
+
if (type) {
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type
|
|
40
|
+
|
|
41
|
+
if (listener) {
|
|
42
|
+
|
|
43
|
+
let capture: boolean
|
|
44
|
+
if (options) capture = typeof options === 'boolean' ? options : options.capture
|
|
45
|
+
|
|
46
|
+
let events: IEventListenerItem[], index: number
|
|
47
|
+
const map = __getListenerMap(this, capture)
|
|
48
|
+
|
|
49
|
+
typeList.forEach(type => {
|
|
50
|
+
if (type) {
|
|
51
|
+
events = map[type]
|
|
52
|
+
if (events) {
|
|
53
|
+
index = events.findIndex(item => item.listener === listener)
|
|
54
|
+
if (index > -1) events.splice(index, 1)
|
|
55
|
+
if (!events.length) delete map[type]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
} else {
|
|
61
|
+
|
|
62
|
+
// off type
|
|
63
|
+
const { __bubbleMap: b, __captureMap: c } = this
|
|
64
|
+
typeList.forEach(type => {
|
|
65
|
+
if (b) delete b[type]
|
|
66
|
+
if (c) delete c[type]
|
|
67
|
+
})
|
|
43
68
|
|
|
44
|
-
typeList.forEach(type => {
|
|
45
|
-
if (type) {
|
|
46
|
-
events = map[type]
|
|
47
|
-
if (events) {
|
|
48
|
-
index = events.findIndex(item => item.listener === listener)
|
|
49
|
-
if (index > -1) events.splice(index, 1)
|
|
50
|
-
if (!events.length) delete map[type]
|
|
51
|
-
}
|
|
52
69
|
}
|
|
53
|
-
|
|
70
|
+
|
|
71
|
+
} else {
|
|
72
|
+
|
|
73
|
+
this.__bubbleMap = this.__captureMap = undefined // off all
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
54
77
|
},
|
|
55
78
|
|
|
56
79
|
on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId {
|
|
@@ -87,6 +110,8 @@ export const LeafEventer: ILeafEventerModule = {
|
|
|
87
110
|
if (event && (event as IEvent).isStopNow) break
|
|
88
111
|
}
|
|
89
112
|
}
|
|
113
|
+
|
|
114
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture)
|
|
90
115
|
},
|
|
91
116
|
|
|
92
117
|
emitEvent(event: IEvent, capture?: boolean): void {
|
|
@@ -95,12 +120,11 @@ export const LeafEventer: ILeafEventerModule = {
|
|
|
95
120
|
},
|
|
96
121
|
|
|
97
122
|
hasEvent(type: string, capture?: boolean): boolean {
|
|
123
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture)) return true
|
|
124
|
+
|
|
98
125
|
const { __bubbleMap: b, __captureMap: c } = this
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
return !!(capture ? (c && c[type]) : (b && b[type]))
|
|
103
|
-
}
|
|
126
|
+
const hasB = b && b[type], hasC = c && c[type]
|
|
127
|
+
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB))
|
|
104
128
|
},
|
|
105
129
|
|
|
106
130
|
}
|
package/src/LeafMatrix.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeafMatrixModule, ILayoutData } from '@leafer/interface'
|
|
1
|
+
import { ILeafMatrixModule, ILayoutData, IScrollPointData } from '@leafer/interface'
|
|
2
2
|
import { AroundHelper, MatrixHelper } from '@leafer/math'
|
|
3
3
|
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
9
9
|
|
|
10
10
|
__updateWorldMatrix(): void {
|
|
11
11
|
|
|
12
|
-
multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__ as ILayoutData)
|
|
12
|
+
multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__ as ILayoutData, this.parent && this.parent.__ as IScrollPointData)
|
|
13
13
|
|
|
14
14
|
},
|
|
15
15
|
|
|
@@ -28,12 +28,12 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
local.e = data.x
|
|
32
|
-
local.f = data.y
|
|
31
|
+
local.e = data.x + data.offsetX
|
|
32
|
+
local.f = data.y + data.offsetY
|
|
33
33
|
|
|
34
|
-
if (data.around) {
|
|
35
|
-
toPoint(data.around, layout.boxBounds, tempPoint)
|
|
36
|
-
translateInner(local, -tempPoint.x, -tempPoint.y)
|
|
34
|
+
if (data.around || data.origin) {
|
|
35
|
+
toPoint(data.around || data.origin, layout.boxBounds, tempPoint)
|
|
36
|
+
translateInner(local, -tempPoint.x, -tempPoint.y, data.origin as unknown as boolean)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
}
|
package/src/LeafRender.ts
CHANGED
|
@@ -5,24 +5,39 @@ export const LeafRender: ILeafRenderModule = {
|
|
|
5
5
|
|
|
6
6
|
__render(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
7
7
|
if (this.__worldOpacity) {
|
|
8
|
-
|
|
9
|
-
canvas.
|
|
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, true)
|
|
13
13
|
|
|
14
|
+
if (this.__.eraser === 'path') return this.__renderEraser(canvas, options)
|
|
15
|
+
|
|
16
|
+
const tempCanvas = canvas.getSameCanvas(true, true)
|
|
14
17
|
this.__draw(tempCanvas, options)
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
canvas.copyWorldByReset(tempCanvas, null, null, blendMode)
|
|
19
|
+
if (this.__worldFlipped) {
|
|
20
|
+
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, this.__.__blendMode, true)
|
|
19
21
|
} else {
|
|
20
|
-
canvas.copyWorldToInner(tempCanvas, this.
|
|
22
|
+
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, this.__.__blendMode)
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
tempCanvas.recycle(this.__nowWorld)
|
|
26
|
+
|
|
23
27
|
} else {
|
|
28
|
+
|
|
24
29
|
this.__draw(canvas, options)
|
|
30
|
+
|
|
25
31
|
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
__clip(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
37
|
+
if (this.__worldOpacity) {
|
|
38
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options))
|
|
39
|
+
this.__drawRenderPath(canvas)
|
|
40
|
+
this.__.windingRule ? canvas.clip(this.__.windingRule) : canvas.clip()
|
|
26
41
|
}
|
|
27
42
|
},
|
|
28
43
|
|
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,
|
|
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,
|
|
15
|
+
export { BranchRender, LeafBounds, LeafDataProxy, LeafEventer, LeafMatrix, LeafRender };
|
package/src/LeafHit.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ILeafHitModule, IRadiusPointData, ILeaferCanvas } from '@leafer/interface'
|
|
2
|
-
import { PointHelper, BoundsHelper } 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
|
-
|
|
23
|
-
if (this.__.hitBox) {
|
|
24
|
-
if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner)) return true
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return this.__hit(inner)
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
__drawHitPath(canvas: ILeaferCanvas): void {
|
|
31
|
-
this.__drawRenderPath(canvas)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
package/src/LeafMask.ts
DELETED
|
@@ -1,48 +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, recycle?: boolean): void {
|
|
15
|
-
content.opacity = 1
|
|
16
|
-
content.resetTransform()
|
|
17
|
-
content.useMask(mask)
|
|
18
|
-
|
|
19
|
-
canvas.opacity = this.__worldOpacity
|
|
20
|
-
canvas.resetTransform()
|
|
21
|
-
canvas.copyWorld(content)
|
|
22
|
-
|
|
23
|
-
if (recycle) {
|
|
24
|
-
content.recycle()
|
|
25
|
-
mask.recycle()
|
|
26
|
-
} else {
|
|
27
|
-
content.clear()
|
|
28
|
-
mask.clear()
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
__removeMask(child?: ILeaf): void {
|
|
33
|
-
if (child) {
|
|
34
|
-
child.isMask = false
|
|
35
|
-
this.remove(child)
|
|
36
|
-
} else {
|
|
37
|
-
const { children } = this
|
|
38
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
39
|
-
child = children[i]
|
|
40
|
-
if (child.isMask) {
|
|
41
|
-
this.__removeMask(child)
|
|
42
|
-
len--, i--
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|