@leafer-ui/render 1.0.0-beta.9 → 1.0.0-rc.10

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,28 +1,31 @@
1
1
  {
2
2
  "name": "@leafer-ui/render",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "@leafer-ui/render",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
13
16
  "url": "https://github.com/leaferjs/ui.git"
14
17
  },
15
- "homepage": "https://github.com/leaferjs/ui/tree/main/packages/render",
18
+ "homepage": "https://github.com/leaferjs/ui/tree/main/packages/display-module/render",
16
19
  "bugs": "https://github.com/leaferjs/ui/issues",
17
20
  "keywords": [
18
21
  "leafer-ui",
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer-ui/external": "1.0.0-beta.9"
25
+ "@leafer-ui/external": "1.0.0-rc.10"
23
26
  },
24
27
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.9",
26
- "@leafer-ui/interface": "1.0.0-beta.9"
28
+ "@leafer/interface": "1.0.0-rc.10",
29
+ "@leafer-ui/interface": "1.0.0-rc.10"
27
30
  }
28
31
  }
package/src/RectRender.ts CHANGED
@@ -18,19 +18,21 @@ export const RectRender: IRectRenderModule = {
18
18
 
19
19
  if (stroke) {
20
20
 
21
- const { strokeAlign, strokeWidth } = this.__
22
- canvas.setStroke(stroke, strokeWidth, this.__)
23
- const half = strokeWidth / 2
21
+ const { strokeAlign, __strokeWidth } = this.__
22
+ if (!__strokeWidth) return
23
+
24
+ canvas.setStroke(stroke, __strokeWidth, this.__)
25
+ const half = __strokeWidth / 2
24
26
 
25
27
  switch (strokeAlign) {
26
28
  case 'center':
27
29
  canvas.strokeRect(0, 0, width, height)
28
30
  break
29
31
  case 'inside':
30
- canvas.strokeRect(half, half, width - strokeWidth, height - strokeWidth)
32
+ canvas.strokeRect(half, half, width - __strokeWidth, height - __strokeWidth)
31
33
  break
32
34
  case 'outside':
33
- canvas.strokeRect(-half, -half, width + strokeWidth, height + strokeWidth)
35
+ canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth)
34
36
  break
35
37
  }
36
38
  }
package/src/UIRender.ts CHANGED
@@ -30,47 +30,51 @@ export const UIRender: IUIRenderModule = {
30
30
 
31
31
  this.__drawRenderPath(canvas)
32
32
 
33
- if (fill) Paint.fill(this, canvas, fill)
33
+ if (fill) Paint.fill(fill as string, this, canvas)
34
34
  if (__drawAfterFill) this.__drawAfterFill(canvas, options)
35
- if (stroke) Paint.stroke(this, canvas, stroke)
35
+ if (stroke) Paint.stroke(stroke as string, this, canvas)
36
36
  },
37
37
 
38
38
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
39
39
 
40
40
  if (this.__.__complex) {
41
41
 
42
- const { fill, stroke, __drawAfterFill } = this.__
42
+ const data = this.__
43
+
44
+ if (data.__needComputePaint) data.__computePaint()
45
+
46
+ const { fill, stroke, __drawAfterFill } = data
43
47
 
44
48
  this.__drawRenderPath(canvas)
45
49
 
46
- if (this.__.__useEffect) {
50
+ if (data.__useEffect) {
47
51
 
48
52
  const shape = Paint.shape(this, canvas, options)
53
+ this.__nowWorld = this.__getNowWorld(options) // restore
49
54
 
50
- const { shadow, innerShadow } = this.__
55
+ const { shadow, innerShadow } = data
51
56
 
52
- if (shadow) Effect.shadow(this, canvas, shape, options)
57
+ if (shadow) Effect.shadow(this, canvas, shape)
53
58
 
54
- if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
59
+ if (fill) data.__isFills ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill(fill as string, this, canvas)
55
60
 
56
61
  if (__drawAfterFill) this.__drawAfterFill(canvas, options)
57
62
 
58
- if (innerShadow) Effect.innerShadow(this, canvas, shape, options)
63
+ if (innerShadow) Effect.innerShadow(this, canvas, shape)
59
64
 
60
- if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
65
+ if (stroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
61
66
 
62
67
  if (shape.worldCanvas) shape.worldCanvas.recycle()
63
68
  shape.canvas.recycle()
64
69
 
65
70
  } else {
66
71
 
67
- if (fill) this.__.__isFills ? Paint.fills(this, canvas, fill as ILeafPaint[]) : Paint.fill(this, canvas, fill)
72
+ if (fill) data.__isFills ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill(fill as string, this, canvas)
68
73
  if (__drawAfterFill) this.__drawAfterFill(canvas, options)
69
- if (stroke) this.__.__isStrokes ? Paint.strokes(this, canvas, stroke as ILeafStrokePaint[]) : Paint.stroke(this, canvas, stroke)
74
+ if (stroke) data.__isStrokes ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke(stroke as string, this, canvas)
70
75
 
71
76
  }
72
77
 
73
-
74
78
  } else {
75
79
 
76
80
  this.__drawFast(canvas, options)
@@ -79,16 +83,16 @@ export const UIRender: IUIRenderModule = {
79
83
  },
80
84
 
81
85
  __renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void {
82
- if (!this.__worldOpacity) return
83
-
84
- canvas.setWorld(this.__world, options.matrix)
86
+ if (this.__worldOpacity) {
87
+ canvas.setWorld(this.__nowWorld = this.__getNowWorld(options))
85
88
 
86
- const { fill, stroke } = this.__
89
+ const { fill, stroke } = this.__
87
90
 
88
- this.__drawRenderPath(canvas)
91
+ this.__drawRenderPath(canvas)
89
92
 
90
- if (fill) Paint.fill(this, canvas, '#000000')
91
- if (stroke) Paint.stroke(this, canvas, '#000000')
93
+ if (fill) this.__.__pixelFill ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill('#000000', this, canvas)
94
+ if (stroke) this.__.__pixelStroke ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke('#000000', this, canvas)
95
+ }
92
96
  }
93
97
 
94
98
  }
@@ -0,0 +1,7 @@
1
+ import { IUIRenderModule, IRectRenderModule } from '@leafer-ui/interface';
2
+
3
+ declare const UIRender: IUIRenderModule;
4
+
5
+ declare const RectRender: IRectRenderModule;
6
+
7
+ export { RectRender, UIRender };