@leafer-ui/render 1.0.0-alpha.23 → 1.0.0-alpha.31
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/RectRender.ts +4 -3
- package/src/TextRender.ts +6 -24
- package/src/UIRender.ts +40 -15
- package/src/index.ts +0 -1
- package/src/FrameRender.ts +0 -40
- package/src/ImageRender.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/render",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.31",
|
|
4
4
|
"description": "@leafer-ui/render",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer-ui/external": "1.0.0-alpha.
|
|
22
|
+
"@leafer-ui/external": "1.0.0-alpha.31"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
26
|
-
"@leafer-ui/interface": "1.0.0-alpha.
|
|
25
|
+
"@leafer/interface": "1.0.0-alpha.31",
|
|
26
|
+
"@leafer-ui/interface": "1.0.0-alpha.31"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/RectRender.ts
CHANGED
|
@@ -5,16 +5,17 @@ import { IRectRenderModule } from '@leafer-ui/interface'
|
|
|
5
5
|
|
|
6
6
|
export const RectRender: IRectRenderModule = {
|
|
7
7
|
|
|
8
|
-
__drawFast(canvas: ILeaferCanvas,
|
|
8
|
+
__drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
9
9
|
|
|
10
|
-
const { width, height, fill, stroke } = this.__
|
|
11
|
-
canvas.smooth = false
|
|
10
|
+
const { width, height, fill, stroke, __drawAfterFill } = this.__
|
|
12
11
|
|
|
13
12
|
if (fill) {
|
|
14
13
|
canvas.fillStyle = fill
|
|
15
14
|
canvas.fillRect(0, 0, width, height)
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
18
|
+
|
|
18
19
|
if (stroke) {
|
|
19
20
|
|
|
20
21
|
const { strokeAlign, strokeWidth } = this.__
|
package/src/TextRender.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import { ITextRenderModule
|
|
3
|
+
import { ITextRenderModule } from '@leafer-ui/interface'
|
|
4
|
+
import { Paint } from '@leafer-ui/external'
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export const TextRender: ITextRenderModule = {
|
|
@@ -8,36 +9,17 @@ export const TextRender: ITextRenderModule = {
|
|
|
8
9
|
__drawFast(canvas: ILeaferCanvas, _options: IRenderOptions): void {
|
|
9
10
|
|
|
10
11
|
const { fill, stroke } = this.__
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
canvas.font = font
|
|
14
|
-
canvas.textBaseline = "alphabetic"
|
|
15
|
-
|
|
16
|
-
let item: ITextRowData
|
|
12
|
+
const { __font } = this.__
|
|
17
13
|
|
|
14
|
+
canvas.font = __font
|
|
18
15
|
|
|
19
16
|
if (fill) {
|
|
20
17
|
canvas.fillStyle = fill
|
|
21
|
-
|
|
22
|
-
item = list[i]
|
|
23
|
-
canvas.fillText(item.text, item.x, item.y)
|
|
24
|
-
|
|
25
|
-
if (decorationY) canvas.fillRect(item.x, item.y + decorationY, item.width, decorationHeight)
|
|
26
|
-
}
|
|
18
|
+
Paint.drawText(this, canvas)
|
|
27
19
|
}
|
|
28
20
|
|
|
29
|
-
if (stroke)
|
|
30
|
-
canvas.strokeStyle = stroke
|
|
31
|
-
for (let i = 0, len = list.length; i < len; i++) {
|
|
32
|
-
item = list[i]
|
|
33
|
-
canvas.strokeText(item.text, item.x, item.y)
|
|
34
|
-
|
|
35
|
-
if (decorationY) canvas.strokeRect(item.x, item.y + decorationY, item.width, decorationHeight)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
21
|
+
if (stroke) Paint.strokeText(this, canvas, stroke)
|
|
38
22
|
|
|
39
23
|
}
|
|
40
24
|
|
|
41
25
|
}
|
|
42
|
-
|
|
43
|
-
TextRender.__draw = TextRender.__drawFast
|
package/src/UIRender.ts
CHANGED
|
@@ -8,7 +8,13 @@ export const UIRender: IUIRenderModule = {
|
|
|
8
8
|
|
|
9
9
|
__updateChange(): void {
|
|
10
10
|
let data = this.__
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
if (data.__useEffect) {
|
|
13
|
+
const { shadow, innerShadow, blur, backgroundBlur } = this.__
|
|
14
|
+
data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect || data.blendMode !== 'pass-through'
|
|
12
18
|
|
|
13
19
|
if (complex) {
|
|
14
20
|
data.__complex = true
|
|
@@ -17,21 +23,29 @@ export const UIRender: IUIRenderModule = {
|
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
25
|
|
|
20
|
-
__drawFast(canvas: ILeaferCanvas,
|
|
21
|
-
const { fill, stroke } = this.__
|
|
26
|
+
__drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
27
|
+
const { fill, stroke, __drawAfterFill } = this.__
|
|
22
28
|
|
|
23
29
|
this.__drawRenderPath(canvas)
|
|
24
|
-
|
|
25
30
|
if (fill) Paint.fill(this, canvas, fill)
|
|
31
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
26
32
|
if (stroke) Paint.stroke(this, canvas, stroke)
|
|
27
33
|
},
|
|
28
34
|
|
|
29
35
|
__draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
36
|
+
|
|
30
37
|
if (this.__.__complex) {
|
|
31
38
|
|
|
32
|
-
const { fill, stroke } = this.__
|
|
39
|
+
const { fill, stroke, __drawAfterFill, __font, __blendLayer } = this.__
|
|
40
|
+
|
|
41
|
+
let orginCanvas: ILeaferCanvas
|
|
42
|
+
|
|
43
|
+
if (__blendLayer) {
|
|
44
|
+
orginCanvas = canvas
|
|
45
|
+
canvas = canvas.getSameCanvas(true)
|
|
46
|
+
}
|
|
33
47
|
|
|
34
|
-
this.__drawRenderPath(canvas)
|
|
48
|
+
__font ? canvas.font = __font : this.__drawRenderPath(canvas)
|
|
35
49
|
|
|
36
50
|
if (this.__.__useEffect) {
|
|
37
51
|
|
|
@@ -43,6 +57,8 @@ export const UIRender: IUIRenderModule = {
|
|
|
43
57
|
|
|
44
58
|
if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
|
|
45
59
|
|
|
60
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
61
|
+
|
|
46
62
|
if (innerShadow) Effect.innerShadow(this, canvas, shape)
|
|
47
63
|
|
|
48
64
|
if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
|
|
@@ -53,7 +69,14 @@ export const UIRender: IUIRenderModule = {
|
|
|
53
69
|
} else {
|
|
54
70
|
|
|
55
71
|
if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
|
|
72
|
+
if (__drawAfterFill) this.__drawAfterFill(canvas, options)
|
|
56
73
|
if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (orginCanvas) {
|
|
78
|
+
orginCanvas.copyWorldToInner(canvas, this.__world, this.__layout.renderBounds, this.__.blendMode)
|
|
79
|
+
canvas.recycle()
|
|
57
80
|
}
|
|
58
81
|
|
|
59
82
|
|
|
@@ -69,18 +92,20 @@ export const UIRender: IUIRenderModule = {
|
|
|
69
92
|
|
|
70
93
|
canvas.setWorld(this.__world, options.matrix)
|
|
71
94
|
|
|
72
|
-
const { fill,
|
|
73
|
-
const { context } = canvas
|
|
95
|
+
const { fill, stroke, __font } = this.__
|
|
74
96
|
|
|
75
|
-
this.__drawRenderPath(canvas)
|
|
97
|
+
__font ? canvas.font = __font : this.__drawRenderPath(canvas)
|
|
76
98
|
|
|
77
|
-
if (fill
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
if (fill) {
|
|
100
|
+
canvas.fillStyle = '#000000'
|
|
101
|
+
__font ? Paint.drawText(this, canvas) : canvas.fill()
|
|
80
102
|
}
|
|
81
|
-
if (stroke
|
|
82
|
-
|
|
83
|
-
|
|
103
|
+
if (stroke) {
|
|
104
|
+
const { strokeWidth, strokeAlign } = this.__
|
|
105
|
+
if (strokeAlign !== 'inside') {
|
|
106
|
+
canvas.setStroke('#000000', strokeAlign === 'outside' ? strokeWidth * 2 : strokeWidth, this.__)
|
|
107
|
+
__font ? Paint.drawTextStroke(this, canvas) : canvas.stroke()
|
|
108
|
+
}
|
|
84
109
|
}
|
|
85
110
|
}
|
|
86
111
|
|
package/src/index.ts
CHANGED
package/src/FrameRender.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
|
-
|
|
3
|
-
import { IFrameRenderModule } from '@leafer-ui/interface'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const FrameRender: IFrameRenderModule = {
|
|
7
|
-
|
|
8
|
-
__render(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
9
|
-
|
|
10
|
-
const { fill, stroke } = this.__
|
|
11
|
-
|
|
12
|
-
if (stroke) this.__.stroke = undefined
|
|
13
|
-
|
|
14
|
-
this.__renderRect(canvas, options)
|
|
15
|
-
|
|
16
|
-
const { clip } = this.__
|
|
17
|
-
if (clip) {
|
|
18
|
-
canvas.save()
|
|
19
|
-
canvas.clip()
|
|
20
|
-
|
|
21
|
-
this.__renderGroup(canvas, options)
|
|
22
|
-
|
|
23
|
-
canvas.restore()
|
|
24
|
-
} else {
|
|
25
|
-
this.__renderGroup(canvas, options)
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (stroke) {
|
|
31
|
-
this.__.stroke = stroke
|
|
32
|
-
|
|
33
|
-
if (fill) this.__.fill = undefined
|
|
34
|
-
this.__renderRect(canvas, options)
|
|
35
|
-
if (fill) this.__.fill = fill
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
package/src/ImageRender.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
|
-
|
|
3
|
-
import { IImageRenderModule } from '@leafer-ui/interface'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const ImageRender: IImageRenderModule = {
|
|
7
|
-
|
|
8
|
-
__draw(_canvas: ILeaferCanvas, _options: IRenderOptions): void {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
}
|