@leafer/path 2.1.1 → 2.1.2
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 +5 -5
- package/src/PathConvert.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/path",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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.
|
|
26
|
-
"@leafer/math": "2.1.
|
|
27
|
-
"@leafer/debug": "2.1.
|
|
25
|
+
"@leafer/data": "2.1.2",
|
|
26
|
+
"@leafer/math": "2.1.2",
|
|
27
|
+
"@leafer/debug": "2.1.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "2.1.
|
|
30
|
+
"@leafer/interface": "2.1.2"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/PathConvert.ts
CHANGED
|
@@ -109,7 +109,7 @@ export const PathConvert = {
|
|
|
109
109
|
|
|
110
110
|
toCanvasData(old: IPathCommandData, curveMode?: boolean): IPathCommandData {
|
|
111
111
|
|
|
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
|
|
112
|
+
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
113
|
const data: IPathCommandData = []
|
|
114
114
|
|
|
115
115
|
while (i < len) {
|
|
@@ -124,7 +124,10 @@ export const PathConvert = {
|
|
|
124
124
|
case M:
|
|
125
125
|
x = old[i + 1]
|
|
126
126
|
y = old[i + 2]
|
|
127
|
-
|
|
127
|
+
|
|
128
|
+
if (lastCommand === command) data.push(L, x, y) // M command followed by multiple coordinates
|
|
129
|
+
else data.push(M, x, y), startX = x, startY = y
|
|
130
|
+
|
|
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
|
|