@leafer/path 1.5.1 → 1.5.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 +4 -4
- package/src/PathCorner.ts +7 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/path",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
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.5.
|
|
26
|
-
"@leafer/debug": "1.5.
|
|
25
|
+
"@leafer/math": "1.5.2",
|
|
26
|
+
"@leafer/debug": "1.5.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.5.
|
|
29
|
+
"@leafer/interface": "1.5.2"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/PathCorner.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { IPathCommandData } from '@leafer/interface'
|
|
2
2
|
import { PointHelper } from '@leafer/math'
|
|
3
3
|
|
|
4
|
-
import { PathCommandMap as Command } from './PathCommandMap'
|
|
4
|
+
import { PathCommandMap as Command, PathNumberCommandLengthMap } from './PathCommandMap'
|
|
5
5
|
import { PathCommandDataHelper } from './PathCommandDataHelper'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
const { M, L,
|
|
8
|
+
const { M, L, Z } = Command
|
|
9
9
|
const { getCenterX, getCenterY } = PointHelper
|
|
10
10
|
const { arcTo } = PathCommandDataHelper
|
|
11
11
|
|
|
12
12
|
export const PathCorner = {
|
|
13
13
|
|
|
14
14
|
smooth(data: IPathCommandData, cornerRadius: number, _cornerSmoothing?: number): IPathCommandData {
|
|
15
|
-
let command: number
|
|
15
|
+
let command: number, commandLen
|
|
16
16
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0
|
|
17
17
|
|
|
18
18
|
const len = data.length
|
|
@@ -50,16 +50,15 @@ export const PathCorner = {
|
|
|
50
50
|
lastX = x
|
|
51
51
|
lastY = y
|
|
52
52
|
break
|
|
53
|
-
case C: //bezierCurveTo(x1, y1, x2, y2, x, y)
|
|
54
|
-
smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6])
|
|
55
|
-
i += 7
|
|
56
|
-
break
|
|
57
53
|
case Z: //closepath()
|
|
58
54
|
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY) // use arcTo(x1, y1, x2, y2, radius)
|
|
59
55
|
smooth.push(Z)
|
|
60
56
|
i += 1
|
|
61
57
|
break
|
|
62
|
-
|
|
58
|
+
default:
|
|
59
|
+
commandLen = PathNumberCommandLengthMap[command]
|
|
60
|
+
for (let j = 0; j < commandLen; j++) smooth.push(data[i + j])
|
|
61
|
+
i += commandLen
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
|