@leafer/path 1.6.7 → 1.7.0

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/path",
3
- "version": "1.6.7",
3
+ "version": "1.7.0",
4
4
  "description": "@leafer/path",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.6.7",
26
- "@leafer/debug": "1.6.7"
25
+ "@leafer/math": "1.7.0",
26
+ "@leafer/debug": "1.7.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.6.7"
29
+ "@leafer/interface": "1.7.0"
30
30
  }
31
31
  }
package/src/PathCorner.ts CHANGED
@@ -12,7 +12,8 @@ const { arcTo } = PathCommandDataHelper
12
12
  export const PathCorner = {
13
13
 
14
14
  smooth(data: IPathCommandData, cornerRadius: number, _cornerSmoothing?: number): IPathCommandData {
15
- let command: number, commandLen
15
+
16
+ let command: number, lastCommand: number, commandLen
16
17
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0
17
18
 
18
19
  const len = data.length
@@ -51,8 +52,10 @@ export const PathCorner = {
51
52
  lastY = y
52
53
  break
53
54
  case Z: //closepath()
54
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY) // use arcTo(x1, y1, x2, y2, radius)
55
- smooth.push(Z)
55
+ if (lastCommand !== Z) { // fix: 重复的 Z 导致的问题
56
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY) // use arcTo(x1, y1, x2, y2, radius)
57
+ smooth.push(Z)
58
+ }
56
59
  i += 1
57
60
  break
58
61
  default:
@@ -60,6 +63,7 @@ export const PathCorner = {
60
63
  for (let j = 0; j < commandLen; j++) smooth.push(data[i + j])
61
64
  i += commandLen
62
65
  }
66
+ lastCommand = command
63
67
  }
64
68
 
65
69
  if (command !== Z) {