@leafer/path
Advanced tools
+4
-4
| { | ||
| "name": "@leafer/path", | ||
| "version": "1.5.1", | ||
| "version": "1.5.2", | ||
| "description": "@leafer/path", | ||
@@ -25,8 +25,8 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/math": "1.5.1", | ||
| "@leafer/debug": "1.5.1" | ||
| "@leafer/math": "1.5.2", | ||
| "@leafer/debug": "1.5.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.5.1" | ||
| "@leafer/interface": "1.5.2" | ||
| } | ||
| } |
| import { IPathCommandData } from '@leafer/interface' | ||
| import { PointHelper } from '@leafer/math' | ||
| import { PathCommandMap as Command } from './PathCommandMap' | ||
| import { PathCommandMap as Command, PathNumberCommandLengthMap } from './PathCommandMap' | ||
| import { PathCommandDataHelper } from './PathCommandDataHelper' | ||
| const { M, L, C, Z } = Command | ||
| const { M, L, Z } = Command | ||
| const { getCenterX, getCenterY } = PointHelper | ||
@@ -15,3 +15,3 @@ const { arcTo } = PathCommandDataHelper | ||
| smooth(data: IPathCommandData, cornerRadius: number, _cornerSmoothing?: number): IPathCommandData { | ||
| let command: number | ||
| let command: number, commandLen | ||
| let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0 | ||
@@ -54,6 +54,2 @@ | ||
| break | ||
| case C: //bezierCurveTo(x1, y1, x2, y2, x, y) | ||
| smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]) | ||
| i += 7 | ||
| break | ||
| case Z: //closepath() | ||
@@ -64,3 +60,6 @@ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY) // use arcTo(x1, y1, x2, y2, radius) | ||
| break | ||
| default: | ||
| commandLen = PathNumberCommandLengthMap[command] | ||
| for (let j = 0; j < commandLen; j++) smooth.push(data[i + j]) | ||
| i += commandLen | ||
| } | ||
@@ -67,0 +66,0 @@ } |
60769
0.03%+ Added
+ Added
- Removed
- Removed
Updated
Updated