@leafer-ui/render 1.0.0-alpha.10 → 1.0.0-alpha.23
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/ImageRender.ts +5 -0
- package/src/RectRender.ts +1 -0
- package/src/TextRender.ts +22 -6
- package/src/UIRender.ts +47 -6
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.23",
|
|
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.23"
|
|
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.23",
|
|
26
|
+
"@leafer-ui/interface": "1.0.0-alpha.23"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/ImageRender.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
|
+
|
|
1
3
|
import { IImageRenderModule } from '@leafer-ui/interface'
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
export const ImageRender: IImageRenderModule = {
|
|
5
7
|
|
|
8
|
+
__draw(_canvas: ILeaferCanvas, _options: IRenderOptions): void {
|
|
9
|
+
|
|
10
|
+
}
|
|
6
11
|
|
|
7
12
|
}
|
package/src/RectRender.ts
CHANGED
package/src/TextRender.ts
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ITextRenderModule, ITextRowData } from '@leafer-ui/interface'
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export const TextRender:
|
|
6
|
+
export const TextRender: ITextRenderModule = {
|
|
7
7
|
|
|
8
8
|
__drawFast(canvas: ILeaferCanvas, _options: IRenderOptions): void {
|
|
9
9
|
|
|
10
|
-
const { fill, stroke
|
|
10
|
+
const { fill, stroke } = this.__
|
|
11
|
+
const { list, font, decorationY, decorationHeight } = this.__.__textDrawData
|
|
12
|
+
|
|
13
|
+
canvas.font = font
|
|
14
|
+
canvas.textBaseline = "alphabetic"
|
|
15
|
+
|
|
16
|
+
let item: ITextRowData
|
|
11
17
|
|
|
12
|
-
canvas.font = __font
|
|
13
18
|
|
|
14
19
|
if (fill) {
|
|
15
20
|
canvas.fillStyle = fill
|
|
16
|
-
|
|
21
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
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
|
+
}
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
if (stroke) {
|
|
20
30
|
canvas.strokeStyle = stroke
|
|
21
|
-
|
|
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
|
+
}
|
|
22
37
|
}
|
|
38
|
+
|
|
23
39
|
}
|
|
24
40
|
|
|
25
41
|
}
|
package/src/UIRender.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
3
|
import { IUIRenderModule, ILeafPaint, ILeafStrokePaint } from '@leafer-ui/interface'
|
|
4
|
-
import { Paint } from '@leafer-ui/external'
|
|
4
|
+
import { Paint, Effect } from '@leafer-ui/external'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export const UIRender: IUIRenderModule = {
|
|
@@ -11,9 +11,9 @@ export const UIRender: IUIRenderModule = {
|
|
|
11
11
|
let complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect
|
|
12
12
|
|
|
13
13
|
if (complex) {
|
|
14
|
-
|
|
14
|
+
data.__complex = true
|
|
15
15
|
} else {
|
|
16
|
-
|
|
16
|
+
data.__complex && (data.__complex = false)
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
|
|
@@ -27,20 +27,61 @@ export const UIRender: IUIRenderModule = {
|
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
__draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
30
|
-
if (this.__complex) {
|
|
30
|
+
if (this.__.__complex) {
|
|
31
31
|
|
|
32
32
|
const { fill, stroke } = this.__
|
|
33
33
|
|
|
34
34
|
this.__drawRenderPath(canvas)
|
|
35
35
|
|
|
36
|
-
if (
|
|
37
|
-
|
|
36
|
+
if (this.__.__useEffect) {
|
|
37
|
+
|
|
38
|
+
const shape = Paint.shape(this, canvas, options)
|
|
39
|
+
|
|
40
|
+
const { shadow, innerShadow } = this.__
|
|
41
|
+
|
|
42
|
+
if (shadow) Effect.shadow(this, canvas, shape)
|
|
43
|
+
|
|
44
|
+
if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
|
|
45
|
+
|
|
46
|
+
if (innerShadow) Effect.innerShadow(this, canvas, shape)
|
|
47
|
+
|
|
48
|
+
if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
|
|
49
|
+
|
|
50
|
+
if (shape.worldCanvas) shape.worldCanvas.recycle()
|
|
51
|
+
shape.canvas.recycle()
|
|
52
|
+
|
|
53
|
+
} else {
|
|
54
|
+
|
|
55
|
+
if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
|
|
56
|
+
if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
|
|
57
|
+
}
|
|
58
|
+
|
|
38
59
|
|
|
39
60
|
} else {
|
|
40
61
|
|
|
41
62
|
this.__drawFast(canvas, options)
|
|
42
63
|
|
|
43
64
|
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
__renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
68
|
+
if (!this.__worldOpacity) return
|
|
69
|
+
|
|
70
|
+
canvas.setWorld(this.__world, options.matrix)
|
|
71
|
+
|
|
72
|
+
const { fill, fills, stroke, strokes } = this.__
|
|
73
|
+
const { context } = canvas
|
|
74
|
+
|
|
75
|
+
this.__drawRenderPath(canvas)
|
|
76
|
+
|
|
77
|
+
if (fill || fills) {
|
|
78
|
+
context.fillStyle = '#000000'
|
|
79
|
+
context.fill()
|
|
80
|
+
}
|
|
81
|
+
if (stroke || strokes) {
|
|
82
|
+
context.lineWidth = 2
|
|
83
|
+
context.stroke()
|
|
84
|
+
}
|
|
44
85
|
}
|
|
45
86
|
|
|
46
87
|
}
|