@leafer-ui/render 1.0.0-beta.12 → 1.0.0-beta.15

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