@leafer-ui/render 1.0.0-alpha.23 → 1.0.0-alpha.30

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/render",
3
- "version": "1.0.0-alpha.23",
3
+ "version": "1.0.0-alpha.30",
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.23"
22
+ "@leafer-ui/external": "1.0.0-alpha.30"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-alpha.23",
26
- "@leafer-ui/interface": "1.0.0-alpha.23"
25
+ "@leafer/interface": "1.0.0-alpha.30",
26
+ "@leafer-ui/interface": "1.0.0-alpha.30"
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, _options: IRenderOptions): void {
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, ITextRowData } from '@leafer-ui/interface'
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 { list, font, decorationY, decorationHeight } = this.__.__textDrawData
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
- 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
- }
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
@@ -17,21 +17,21 @@ export const UIRender: IUIRenderModule = {
17
17
  }
18
18
  },
19
19
 
20
- __drawFast(canvas: ILeaferCanvas, _options: IRenderOptions): void {
21
- const { fill, stroke } = this.__
20
+ __drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {
21
+ const { fill, stroke, __drawAfterFill } = this.__
22
22
 
23
23
  this.__drawRenderPath(canvas)
24
-
25
24
  if (fill) Paint.fill(this, canvas, fill)
25
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
26
26
  if (stroke) Paint.stroke(this, canvas, stroke)
27
27
  },
28
28
 
29
29
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
30
30
  if (this.__.__complex) {
31
31
 
32
- const { fill, stroke } = this.__
32
+ const { fill, stroke, __drawAfterFill, __font } = this.__
33
33
 
34
- this.__drawRenderPath(canvas)
34
+ __font ? canvas.font = __font : this.__drawRenderPath(canvas)
35
35
 
36
36
  if (this.__.__useEffect) {
37
37
 
@@ -43,6 +43,8 @@ export const UIRender: IUIRenderModule = {
43
43
 
44
44
  if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
45
45
 
46
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
47
+
46
48
  if (innerShadow) Effect.innerShadow(this, canvas, shape)
47
49
 
48
50
  if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
@@ -51,8 +53,8 @@ export const UIRender: IUIRenderModule = {
51
53
  shape.canvas.recycle()
52
54
 
53
55
  } else {
54
-
55
56
  if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
57
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
56
58
  if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
57
59
  }
58
60
 
@@ -69,18 +71,20 @@ export const UIRender: IUIRenderModule = {
69
71
 
70
72
  canvas.setWorld(this.__world, options.matrix)
71
73
 
72
- const { fill, fills, stroke, strokes } = this.__
73
- const { context } = canvas
74
+ const { fill, stroke, __font } = this.__
74
75
 
75
- this.__drawRenderPath(canvas)
76
+ __font ? canvas.font = __font : this.__drawRenderPath(canvas)
76
77
 
77
- if (fill || fills) {
78
- context.fillStyle = '#000000'
79
- context.fill()
78
+ if (fill) {
79
+ canvas.fillStyle = '#000000'
80
+ __font ? Paint.drawText(this, canvas) : canvas.fill()
80
81
  }
81
- if (stroke || strokes) {
82
- context.lineWidth = 2
83
- context.stroke()
82
+ if (stroke) {
83
+ const { strokeWidth, strokeAlign } = this.__
84
+ if (strokeAlign !== 'inside') {
85
+ canvas.setStroke('#000000', strokeAlign === 'outside' ? strokeWidth * 2 : strokeWidth, this.__)
86
+ __font ? Paint.drawTextStroke(this, canvas) : canvas.stroke()
87
+ }
84
88
  }
85
89
  }
86
90
 
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { UIRender } from './UIRender'
2
- export { FrameRender } from './FrameRender'
3
2
  export { RectRender } from './RectRender'
4
3
  export { TextRender } from './TextRender'
@@ -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
- }
@@ -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
- }