@leafer-ui/render 1.0.0-alpha.21 → 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.21",
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.21"
22
+ "@leafer-ui/external": "1.0.0-alpha.30"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-alpha.21",
26
- "@leafer-ui/interface": "1.0.0-alpha.21"
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,15 +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.__
10
+ const { width, height, fill, stroke, __drawAfterFill } = this.__
11
11
 
12
12
  if (fill) {
13
13
  canvas.fillStyle = fill
14
14
  canvas.fillRect(0, 0, width, height)
15
15
  }
16
16
 
17
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
18
+
17
19
  if (stroke) {
18
20
 
19
21
  const { strokeAlign, strokeWidth } = this.__
package/src/TextRender.ts CHANGED
@@ -1,27 +1,25 @@
1
1
  import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
2
2
 
3
- import { IUIRenderModule } from '@leafer-ui/interface'
3
+ import { ITextRenderModule } from '@leafer-ui/interface'
4
+ import { Paint } from '@leafer-ui/external'
4
5
 
5
6
 
6
- export const TextRender: IUIRenderModule = {
7
+ export const TextRender: ITextRenderModule = {
7
8
 
8
9
  __drawFast(canvas: ILeaferCanvas, _options: IRenderOptions): void {
9
10
 
10
- const { fill, stroke, content, __font } = this.__
11
+ const { fill, stroke } = this.__
12
+ const { __font } = this.__
11
13
 
12
14
  canvas.font = __font
13
15
 
14
16
  if (fill) {
15
17
  canvas.fillStyle = fill
16
- canvas.fillText(content, 0, 0)
18
+ Paint.drawText(this, canvas)
17
19
  }
18
20
 
19
- if (stroke) {
20
- canvas.strokeStyle = stroke
21
- canvas.strokeText(content, 0, 0)
22
- }
21
+ if (stroke) Paint.strokeText(this, canvas, stroke)
22
+
23
23
  }
24
24
 
25
25
  }
26
-
27
- TextRender.__draw = TextRender.__drawFast
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 = {
@@ -17,30 +17,75 @@ 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
+
34
+ __font ? canvas.font = __font : this.__drawRenderPath(canvas)
35
+
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 (__drawAfterFill) this.__drawAfterFill(canvas, options)
47
+
48
+ if (innerShadow) Effect.innerShadow(this, canvas, shape)
49
+
50
+ if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
33
51
 
34
- this.__drawRenderPath(canvas)
52
+ if (shape.worldCanvas) shape.worldCanvas.recycle()
53
+ shape.canvas.recycle()
54
+
55
+ } else {
56
+ if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
57
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
58
+ if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
59
+ }
35
60
 
36
- if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
37
- if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
38
61
 
39
62
  } else {
40
63
 
41
64
  this.__drawFast(canvas, options)
42
65
 
43
66
  }
67
+ },
68
+
69
+ __renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void {
70
+ if (!this.__worldOpacity) return
71
+
72
+ canvas.setWorld(this.__world, options.matrix)
73
+
74
+ const { fill, stroke, __font } = this.__
75
+
76
+ __font ? canvas.font = __font : this.__drawRenderPath(canvas)
77
+
78
+ if (fill) {
79
+ canvas.fillStyle = '#000000'
80
+ __font ? Paint.drawText(this, canvas) : canvas.fill()
81
+ }
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
+ }
88
+ }
44
89
  }
45
90
 
46
91
  }
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
- }