@leafer-ui/render 1.0.0-alpha.9 → 1.0.0-beta

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.9",
3
+ "version": "1.0.0-beta",
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.9"
22
+ "@leafer-ui/external": "1.0.0-beta"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-alpha.9",
26
- "@leafer-ui/interface": "1.0.0-alpha.9"
25
+ "@leafer/interface": "1.0.0-beta",
26
+ "@leafer-ui/interface": "1.0.0-beta"
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/UIRender.ts CHANGED
@@ -1,38 +1,104 @@
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 = {
8
8
 
9
9
  __updateChange(): void {
10
10
  let data = this.__
11
- let complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect
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 && data.blendMode !== 'pass-through')
12
18
 
13
19
  if (complex) {
14
- this.__complex = true
20
+ data.__complex = true
15
21
  } else {
16
- this.__complex && (this.__complex = false)
22
+ data.__complex && (data.__complex = false)
17
23
  }
18
24
  },
19
25
 
20
- __drawFast(canvas: ILeaferCanvas, _options: IRenderOptions): void {
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
30
 
25
31
  if (fill) Paint.fill(this, canvas, fill)
32
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
26
33
  if (stroke) Paint.stroke(this, canvas, stroke)
27
34
  },
28
35
 
29
- __draw(canvas: ILeaferCanvas, _options: IRenderOptions): void {
36
+ __draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
37
+
38
+ if (this.__.__complex) {
39
+
40
+ const { fill, stroke, __drawAfterFill, __blendLayer } = this.__
41
+
42
+ let orginCanvas: ILeaferCanvas
43
+
44
+ if (__blendLayer) {
45
+ orginCanvas = canvas
46
+ canvas = canvas.getSameCanvas(true)
47
+ }
48
+
49
+ this.__drawRenderPath(canvas)
50
+
51
+ if (this.__.__useEffect) {
52
+
53
+ const shape = Paint.shape(this, canvas, options)
54
+
55
+ const { shadow, innerShadow } = this.__
56
+
57
+ if (shadow) Effect.shadow(this, canvas, shape)
58
+
59
+ if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
60
+
61
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
62
+
63
+ if (innerShadow) Effect.innerShadow(this, canvas, shape)
64
+
65
+ if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
66
+
67
+ if (shape.worldCanvas) shape.worldCanvas.recycle()
68
+ shape.canvas.recycle()
69
+
70
+ } else {
71
+
72
+ if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
73
+ if (__drawAfterFill) this.__drawAfterFill(canvas, options)
74
+ if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
75
+
76
+ }
77
+
78
+ if (orginCanvas) {
79
+ orginCanvas.copyWorldToInner(canvas, this.__world, this.__layout.renderBounds, this.__.blendMode)
80
+ canvas.recycle()
81
+ }
82
+
83
+
84
+ } else {
85
+
86
+ this.__drawFast(canvas, options)
87
+
88
+ }
89
+ },
90
+
91
+ __renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void {
92
+ if (!this.__worldOpacity) return
93
+
94
+ canvas.setWorld(this.__world, options.matrix)
95
+
30
96
  const { fill, stroke } = this.__
31
97
 
32
98
  this.__drawRenderPath(canvas)
33
99
 
34
- if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
35
- if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
100
+ if (fill) Paint.fill(this, canvas, '#000000')
101
+ if (stroke) Paint.stroke(this, canvas, '#000000')
36
102
  }
37
103
 
38
104
  }
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { UIRender } from './UIRender'
2
- export { FrameRender } from './FrameRender'
3
2
  export { RectRender } from './RectRender'
4
- 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
- }
package/src/TextRender.ts DELETED
@@ -1,27 +0,0 @@
1
- import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
2
-
3
- import { IUIRenderModule } from '@leafer-ui/interface'
4
-
5
-
6
- export const TextRender: IUIRenderModule = {
7
-
8
- __drawFast(canvas: ILeaferCanvas, _options: IRenderOptions): void {
9
-
10
- const { fill, stroke, content, __font } = this.__
11
-
12
- canvas.font = __font
13
-
14
- if (fill) {
15
- canvas.fillStyle = fill
16
- canvas.fillText(content, 0, 0)
17
- }
18
-
19
- if (stroke) {
20
- canvas.strokeStyle = stroke
21
- canvas.strokeText(content, 0, 0)
22
- }
23
- }
24
-
25
- }
26
-
27
- TextRender.__draw = TextRender.__drawFast