@leafer/path 2.1.1 → 2.1.3

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/PathConvert.ts +10 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/path",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "@leafer/path",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/data": "2.1.1",
26
- "@leafer/math": "2.1.1",
27
- "@leafer/debug": "2.1.1"
25
+ "@leafer/data": "2.1.3",
26
+ "@leafer/math": "2.1.3",
27
+ "@leafer/debug": "2.1.3"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "2.1.1"
30
+ "@leafer/interface": "2.1.3"
31
31
  }
32
32
  }
@@ -79,7 +79,10 @@ export const PathConvert = {
79
79
  current.index = 0
80
80
  pushData(data, current.name)
81
81
 
82
- if (!needConvert && convertCommand[char]) needConvert = true
82
+ // m/M命令连续数据需转成l/L: m1 1 2 2m5 5 6 6
83
+ if (char === 'm') current.name = Command['l']
84
+ else if (char === 'M') current.name = Command['L']
85
+ else if (!needConvert && convertCommand[char]) needConvert = true
83
86
 
84
87
  } else {
85
88
 
@@ -109,7 +112,7 @@ export const PathConvert = {
109
112
 
110
113
  toCanvasData(old: IPathCommandData, curveMode?: boolean): IPathCommandData {
111
114
 
112
- let x = 0, y = 0, x1 = 0, y1 = 0, i = 0, len = old.length, controlX: number, controlY: number, command: number, lastCommand: number, smooth: boolean
115
+ let x = 0, y = 0, x1 = 0, y1 = 0, startX = 0, startY = 0, i = 0, len = old.length, controlX: number, controlY: number, command: number, lastCommand: number, smooth: boolean
113
116
  const data: IPathCommandData = []
114
117
 
115
118
  while (i < len) {
@@ -122,9 +125,9 @@ export const PathConvert = {
122
125
  old[i + 1] += x
123
126
  old[i + 2] += y
124
127
  case M:
125
- x = old[i + 1]
126
- y = old[i + 2]
127
- data.push(lastCommand === command ? L : M, x, y) // M command followed by multiple coordinates
128
+ x = startX = old[i + 1]
129
+ y = startY = old[i + 2]
130
+ data.push(M, x, y)
128
131
  i += 3
129
132
  break
130
133
 
@@ -238,6 +241,8 @@ export const PathConvert = {
238
241
  case z:
239
242
  case Z:
240
243
  data.push(Z)
244
+ x = startX
245
+ y = startY
241
246
  i++
242
247
  break
243
248