@leafer/path 1.0.0-alpha.1 → 1.0.0-alpha.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,11 +1,13 @@
1
1
  {
2
2
  "name": "@leafer/path",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.10",
4
4
  "description": "@leafer/path",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
- "files": ["src"],
8
+ "files": [
9
+ "src"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/leaferjs/leafer.git"
@@ -17,9 +19,9 @@
17
19
  "leaferjs"
18
20
  ],
19
21
  "dependencies": {
20
- "@leafer/math": "1.0.0-alpha.1"
22
+ "@leafer/math": "1.0.0-alpha.10"
21
23
  },
22
24
  "devDependencies": {
23
- "@leafer/interface": "1.0.0-alpha.1"
25
+ "@leafer/interface": "1.0.0-alpha.10"
24
26
  }
25
- }
27
+ }
@@ -12,7 +12,7 @@ export const PathCreator = {
12
12
  },
13
13
 
14
14
  end(): void {
15
- data = undefined
15
+ data = null
16
16
  },
17
17
 
18
18
  // draw
@@ -35,7 +35,7 @@ export const PathCreator = {
35
35
 
36
36
  close(end?: boolean): void {
37
37
  data.push(Z)
38
- if (end) data = undefined
38
+ if (end) data = null
39
39
  },
40
40
 
41
41
 
package/src/PathHelper.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICanvasDrawPath, ITwoPointBoundsData, IPathCommandData } from '@leafer/interface'
1
+ import { IPathDrawer, ITwoPointBoundsData, IPathCommandData } from '@leafer/interface'
2
2
  import { TwoPointBoundsHelper } from '@leafer/math'
3
3
 
4
4
  import { BezierHelper } from './BezierHelper'
@@ -13,7 +13,7 @@ const tempPointBounds = {} as ITwoPointBoundsData
13
13
 
14
14
  export const PathHelper = {
15
15
 
16
- applyCorner(data: IPathCommandData, cornerRadius: number, cornerSmoothing?: number): IPathCommandData {
16
+ smoothCorner(data: IPathCommandData, _cornerRadius: number, _cornerSmoothing?: number): IPathCommandData {
17
17
  return data
18
18
  },
19
19
 
@@ -73,39 +73,41 @@ export const PathHelper = {
73
73
 
74
74
  },
75
75
 
76
- drawData(drawer: ICanvasDrawPath, data: IPathCommandData): void {
77
- let command: number
78
- let i = 0, len = data.length
79
-
80
- while (i < len) {
81
- command = data[i]
82
- switch (command) {
83
- case M: //moveto x,y
84
- drawer.moveTo(data[i + 1], data[i + 2])
85
- i += 3
86
- break
87
- case L: //lineto x,y
88
- drawer.lineTo(data[i + 1], data[i + 2])
89
- i += 3
90
- break
91
- case C: //bezierCurveTo x1,y1,x2,y2,x,y
92
- drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6])
93
- i += 7
94
- break
95
- case Q: //quadraticCurveTo x1,y1,x,y
96
- drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
97
- i += 5
98
- break
99
- case Z: //closepath
100
- drawer.closePath()
101
- i += 1
102
- break
103
-
104
- // 非svg标准的canvas绘图命令
105
- case E:
106
- drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8] as unknown as boolean)
107
- i += 9
108
- break
76
+ drawData(drawer: IPathDrawer, data: IPathCommandData): void {
77
+ if (data) {
78
+ let command: number
79
+ let i = 0, len = data.length
80
+
81
+ while (i < len) {
82
+ command = data[i]
83
+ switch (command) {
84
+ case M: //moveto x,y
85
+ drawer.moveTo(data[i + 1], data[i + 2])
86
+ i += 3
87
+ break
88
+ case L: //lineto x,y
89
+ drawer.lineTo(data[i + 1], data[i + 2])
90
+ i += 3
91
+ break
92
+ case C: //bezierCurveTo x1,y1,x2,y2,x,y
93
+ drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6])
94
+ i += 7
95
+ break
96
+ case Q: //quadraticCurveTo x1,y1,x,y
97
+ drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
98
+ i += 5
99
+ break
100
+ case Z: //closepath
101
+ drawer.closePath()
102
+ i += 1
103
+ break
104
+
105
+ // 非svg标准的canvas绘图命令
106
+ case E:
107
+ drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8] as unknown as boolean)
108
+ i += 9
109
+ break
110
+ }
109
111
  }
110
112
  }
111
113
  }