@leafer-ui/render 1.0.0-rc.2 → 1.0.0-rc.21
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 +5 -5
- package/src/RectRender.ts +7 -5
- package/src/UIRender.ts +40 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/render",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.21",
|
|
4
4
|
"description": "@leafer-ui/render",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/leaferjs/ui.git"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/render",
|
|
18
|
+
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/display-module/render",
|
|
19
19
|
"bugs": "https://github.com/leaferjs/ui/issues",
|
|
20
20
|
"keywords": [
|
|
21
21
|
"leafer-ui",
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer-ui/external": "1.0.0-rc.
|
|
25
|
+
"@leafer-ui/external": "1.0.0-rc.21"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.0-rc.
|
|
29
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
28
|
+
"@leafer/interface": "1.0.0-rc.21",
|
|
29
|
+
"@leafer-ui/interface": "1.0.0-rc.21"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/RectRender.ts
CHANGED
|
@@ -18,19 +18,21 @@ export const RectRender: IRectRenderModule = {
|
|
|
18
18
|
|
|
19
19
|
if (stroke) {
|
|
20
20
|
|
|
21
|
-
const { strokeAlign,
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const { strokeAlign, __strokeWidth } = this.__
|
|
22
|
+
if (!__strokeWidth) return
|
|
23
|
+
|
|
24
|
+
canvas.setStroke(stroke, __strokeWidth, this.__)
|
|
25
|
+
const half = __strokeWidth / 2
|
|
24
26
|
|
|
25
27
|
switch (strokeAlign) {
|
|
26
28
|
case 'center':
|
|
27
29
|
canvas.strokeRect(0, 0, width, height)
|
|
28
30
|
break
|
|
29
31
|
case 'inside':
|
|
30
|
-
canvas.strokeRect(half, half, width -
|
|
32
|
+
canvas.strokeRect(half, half, width - __strokeWidth, height - __strokeWidth)
|
|
31
33
|
break
|
|
32
34
|
case 'outside':
|
|
33
|
-
canvas.strokeRect(-half, -half, width +
|
|
35
|
+
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth)
|
|
34
36
|
break
|
|
35
37
|
}
|
|
36
38
|
}
|
package/src/UIRender.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import { IUIRenderModule, ILeafPaint, ILeafStrokePaint } from '@leafer-ui/interface'
|
|
3
|
+
import { IUIRenderModule, ILeafPaint, ILeafStrokePaint, IUI } from '@leafer-ui/interface'
|
|
4
4
|
import { Paint, Effect } from '@leafer-ui/external'
|
|
5
5
|
|
|
6
6
|
|
|
@@ -26,69 +26,81 @@ export const UIRender: IUIRenderModule = {
|
|
|
26
26
|
},
|
|
27
27
|
|
|
28
28
|
__drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.__drawRenderPath(canvas)
|
|
32
|
-
|
|
33
|
-
if (fill) Paint.fill(this, canvas, fill as string)
|
|
34
|
-
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
35
|
-
if (stroke) Paint.stroke(this, canvas, stroke as string)
|
|
29
|
+
drawFast(this, canvas, options)
|
|
36
30
|
},
|
|
37
31
|
|
|
38
32
|
__draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
33
|
+
const data = this.__
|
|
34
|
+
|
|
35
|
+
if (data.__complex) {
|
|
39
36
|
|
|
40
|
-
|
|
37
|
+
if (data.__needComputePaint) data.__computePaint()
|
|
41
38
|
|
|
42
|
-
const { fill, stroke, __drawAfterFill } =
|
|
39
|
+
const { fill, stroke, __drawAfterFill } = data
|
|
43
40
|
|
|
44
41
|
this.__drawRenderPath(canvas)
|
|
45
42
|
|
|
46
|
-
if (
|
|
43
|
+
if (data.__useEffect) {
|
|
47
44
|
|
|
48
45
|
const shape = Paint.shape(this, canvas, options)
|
|
46
|
+
this.__nowWorld = this.__getNowWorld(options) // restore
|
|
49
47
|
|
|
50
|
-
const { shadow, innerShadow } =
|
|
48
|
+
const { shadow, innerShadow } = data
|
|
51
49
|
|
|
52
|
-
if (shadow) Effect.shadow(this, canvas, shape
|
|
50
|
+
if (shadow) Effect.shadow(this, canvas, shape)
|
|
53
51
|
|
|
54
|
-
if (fill)
|
|
52
|
+
if (fill) data.__isFills ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill(fill as string, this, canvas)
|
|
55
53
|
|
|
56
54
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
57
55
|
|
|
58
|
-
if (innerShadow) Effect.innerShadow(this, canvas, shape
|
|
56
|
+
if (innerShadow) Effect.innerShadow(this, canvas, shape)
|
|
59
57
|
|
|
60
|
-
if (stroke)
|
|
58
|
+
if (stroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
61
59
|
|
|
62
60
|
if (shape.worldCanvas) shape.worldCanvas.recycle()
|
|
63
61
|
shape.canvas.recycle()
|
|
64
62
|
|
|
65
63
|
} else {
|
|
66
64
|
|
|
67
|
-
if (fill)
|
|
65
|
+
if (fill) data.__isFills ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill(fill as string, this, canvas)
|
|
68
66
|
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
69
|
-
if (stroke)
|
|
67
|
+
if (stroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
|
|
70
68
|
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
|
|
74
71
|
} else {
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
if (data.__pathInputed) {
|
|
74
|
+
drawFast(this, canvas, options)
|
|
75
|
+
} else {
|
|
76
|
+
this.__drawFast(canvas, options)
|
|
77
|
+
}
|
|
77
78
|
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
81
|
|
|
81
|
-
__renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
82
|
-
if (
|
|
82
|
+
__renderShape(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void {
|
|
83
|
+
if (this.__worldOpacity) {
|
|
84
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options))
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
const { fill, stroke } = this.__
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.__drawRenderPath(canvas)
|
|
88
|
+
this.__drawRenderPath(canvas)
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
if (fill && !ignoreFill) this.__.__pixelFill ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill('#000000', this, canvas)
|
|
91
|
+
if (stroke && !ignoreStroke) this.__.__pixelStroke ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke('#000000', this, canvas)
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
function drawFast(ui: IUI, canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
99
|
+
const { fill, stroke, __drawAfterFill } = ui.__
|
|
100
|
+
|
|
101
|
+
ui.__drawRenderPath(canvas)
|
|
102
|
+
|
|
103
|
+
if (fill) Paint.fill(fill as string, ui, canvas)
|
|
104
|
+
if (__drawAfterFill) ui.__drawAfterFill(canvas, options)
|
|
105
|
+
if (stroke) Paint.stroke(stroke as string, ui, canvas)
|
|
94
106
|
}
|