@leafer-ui/render 1.6.1 → 1.6.3
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/UIRender.ts +37 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/render",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "@leafer-ui/render",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer-ui/external": "1.6.
|
|
25
|
+
"@leafer-ui/external": "1.6.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.6.
|
|
29
|
-
"@leafer-ui/interface": "1.6.
|
|
28
|
+
"@leafer/interface": "1.6.3",
|
|
29
|
+
"@leafer-ui/interface": "1.6.3"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/UIRender.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
|
+
import { DataHelper } from '@leafer/core'
|
|
2
3
|
|
|
3
4
|
import { IUIRenderModule, ILeafPaint, ILeafStrokePaint, IUI } from '@leafer-ui/interface'
|
|
4
|
-
import { Paint, Effect, Filter } from '@leafer-ui/external'
|
|
5
|
+
import { Paint, Effect, Filter, ColorConvert } from '@leafer-ui/external'
|
|
5
6
|
|
|
7
|
+
const { stintSet } = DataHelper
|
|
6
8
|
|
|
7
9
|
export const UIRender: IUIRenderModule = {
|
|
8
10
|
|
|
9
11
|
__updateChange(): void {
|
|
10
|
-
const data = this.__
|
|
12
|
+
const data = this.__
|
|
11
13
|
|
|
12
14
|
if (data.__useEffect) {
|
|
13
|
-
const { shadow,
|
|
14
|
-
data.
|
|
15
|
+
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter
|
|
16
|
+
stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')))
|
|
17
|
+
data.__useEffect = !!(shadow || otherEffect)
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
w.half !== half && (w.half = half)
|
|
20
|
+
stintSet(this.__world, 'half', data.__hasHalf)
|
|
19
21
|
|
|
20
|
-
data.
|
|
22
|
+
stintSet(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill)
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
data.__checkSingle()
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
else data.__complex && (data.__complex = false)
|
|
26
|
+
stintSet(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect)
|
|
26
27
|
},
|
|
27
28
|
|
|
28
29
|
__drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
@@ -36,11 +37,11 @@ export const UIRender: IUIRenderModule = {
|
|
|
36
37
|
|
|
37
38
|
if (data.__needComputePaint) data.__computePaint()
|
|
38
39
|
|
|
39
|
-
const { fill, stroke, __drawAfterFill } = data
|
|
40
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data
|
|
40
41
|
|
|
41
42
|
this.__drawRenderPath(canvas)
|
|
42
43
|
|
|
43
|
-
if (data.__useEffect) {
|
|
44
|
+
if (data.__useEffect && !__isFastShadow) {
|
|
44
45
|
|
|
45
46
|
const shape = Paint.shape(this, canvas, options)
|
|
46
47
|
this.__nowWorld = this.__getNowWorld(options) // restore
|
|
@@ -49,13 +50,15 @@ export const UIRender: IUIRenderModule = {
|
|
|
49
50
|
|
|
50
51
|
if (shadow) Effect.shadow(this, canvas, shape)
|
|
51
52
|
|
|
53
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
54
|
+
|
|
52
55
|
if (fill) data.__isFills ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill(fill as string, this, canvas)
|
|
53
56
|
|
|
54
57
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
55
58
|
|
|
56
59
|
if (innerShadow) Effect.innerShadow(this, canvas, shape)
|
|
57
60
|
|
|
58
|
-
if (stroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
61
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
59
62
|
|
|
60
63
|
if (filter) Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape)
|
|
61
64
|
|
|
@@ -64,19 +67,27 @@ export const UIRender: IUIRenderModule = {
|
|
|
64
67
|
|
|
65
68
|
} else {
|
|
66
69
|
|
|
70
|
+
if (__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
71
|
+
|
|
72
|
+
if (__isFastShadow) {
|
|
73
|
+
const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld
|
|
74
|
+
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color))
|
|
75
|
+
}
|
|
76
|
+
|
|
67
77
|
if (fill) data.__isFills ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill(fill as string, this, canvas)
|
|
78
|
+
|
|
79
|
+
if (__isFastShadow) canvas.restore()
|
|
80
|
+
|
|
68
81
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
69
|
-
|
|
82
|
+
|
|
83
|
+
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
70
84
|
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
} else {
|
|
74
88
|
|
|
75
|
-
if (data.__pathInputed)
|
|
76
|
-
|
|
77
|
-
} else {
|
|
78
|
-
this.__drawFast(canvas, options)
|
|
79
|
-
}
|
|
89
|
+
if (data.__pathInputed) drawFast(this, canvas, options)
|
|
90
|
+
else this.__drawFast(canvas, options)
|
|
80
91
|
|
|
81
92
|
}
|
|
82
93
|
},
|
|
@@ -89,9 +100,9 @@ export const UIRender: IUIRenderModule = {
|
|
|
89
100
|
|
|
90
101
|
this.__drawRenderPath(canvas)
|
|
91
102
|
|
|
92
|
-
if (fill && !ignoreFill) this.__.
|
|
103
|
+
if (fill && !ignoreFill) this.__.__isAlphaPixelFill ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill('#000000', this, canvas)
|
|
93
104
|
if (this.__.__isCanvas) this.__drawAfterFill(canvas, options)
|
|
94
|
-
if (stroke && !ignoreStroke) this.__.
|
|
105
|
+
if (stroke && !ignoreStroke) this.__.__isAlphaPixelStroke ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke('#000000', this, canvas)
|
|
95
106
|
}
|
|
96
107
|
},
|
|
97
108
|
|
|
@@ -108,11 +119,14 @@ export const UIRender: IUIRenderModule = {
|
|
|
108
119
|
|
|
109
120
|
|
|
110
121
|
function drawFast(ui: IUI, canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
111
|
-
const { fill, stroke, __drawAfterFill } = ui.__
|
|
122
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__
|
|
112
123
|
|
|
113
124
|
ui.__drawRenderPath(canvas)
|
|
114
125
|
|
|
126
|
+
if (__fillAfterStroke) Paint.stroke(stroke as string, ui, canvas)
|
|
127
|
+
|
|
115
128
|
if (fill) Paint.fill(fill as string, ui, canvas)
|
|
116
129
|
if (__drawAfterFill) ui.__drawAfterFill(canvas, options)
|
|
117
|
-
|
|
130
|
+
|
|
131
|
+
if (stroke && !__fillAfterStroke) Paint.stroke(stroke as string, ui, canvas)
|
|
118
132
|
}
|