@leafer/path
Advanced tools
+4
-4
| { | ||
| "name": "@leafer/path", | ||
| "version": "1.0.0-rc.5", | ||
| "version": "1.0.0-rc.6", | ||
| "description": "@leafer/path", | ||
@@ -25,8 +25,8 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/math": "1.0.0-rc.5", | ||
| "@leafer/debug": "1.0.0-rc.5" | ||
| "@leafer/math": "1.0.0-rc.6", | ||
| "@leafer/debug": "1.0.0-rc.6" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.0.0-rc.5" | ||
| "@leafer/interface": "1.0.0-rc.6" | ||
| } | ||
| } |
@@ -61,3 +61,3 @@ import { IPathCommandData } from '@leafer/interface' | ||
| if (curveMode || Platform.name === 'node') { | ||
| if (curveMode || Platform.ellipseToCurve) { | ||
| ellipse(data, centerX, centerY, radiusX, radiusY, rotation, startRadian / OneRadian, endRadian / OneRadian, anticlockwise as unknown as boolean) | ||
@@ -64,0 +64,0 @@ } else { |
+59
-2
| import { IPathCommandData } from '@leafer/interface' | ||
| import { PathCommandMap as Command } from './PathCommandMap' | ||
| const { M, L, C, Z, U } = Command | ||
| export const PathCorner = { | ||
| smooth(data: IPathCommandData, _cornerRadius: number, _cornerSmoothing?: number): IPathCommandData { | ||
| return data | ||
| smooth(data: IPathCommandData, cornerRadius: number, _cornerSmoothing?: number): IPathCommandData { | ||
| let command: number | ||
| let i: number = 0, x: number = 0, y: number = 0, startX: number, startY = 0, centerX: number = 0, centerY: number = 0 | ||
| const len = data.length | ||
| const smooth: IPathCommandData = [] | ||
| while (i < len) { | ||
| command = data[i] | ||
| switch (command) { | ||
| case M: //moveto(x, y) | ||
| startX = data[i + 1] | ||
| startY = data[i + 2] | ||
| i += 3 | ||
| if (data[i] === L) { // next lineTo | ||
| centerX = startX + (data[i + 1] - startX) / 2 | ||
| centerY = startY + (data[i + 2] - startY) / 2 | ||
| smooth.push(M, centerX, centerY) | ||
| } else { | ||
| smooth.push(M, startX, startY) | ||
| } | ||
| break | ||
| case L: //lineto(x, y) | ||
| x = data[i + 1] | ||
| y = data[i + 2] | ||
| i += 3 | ||
| switch (data[i]) { // next command | ||
| case L: // lineTo() | ||
| smooth.push(U, x, y, data[i + 1], data[i + 2], cornerRadius) // use arcTo(x1, y1, x2, y2, radius) | ||
| break | ||
| case Z: // closePath() | ||
| smooth.push(U, x, y, startX, startY, cornerRadius) // use arcTo(x1, y1, x2, y2, radius) | ||
| break | ||
| default: | ||
| smooth.push(L, x, y) | ||
| } | ||
| 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() | ||
| smooth.push(U, startX, startY, centerX, centerY, cornerRadius) // use arcTo(x1, y1, x2, y2, radius) | ||
| smooth.push(Z) | ||
| i += 1 | ||
| break | ||
| } | ||
| } | ||
| if (command !== Z) { | ||
| smooth[1] = startX | ||
| smooth[2] = startY | ||
| } | ||
| return smooth | ||
| } | ||
| } |
+1
-1
@@ -70,3 +70,3 @@ import { IPathCreator, IPathCommandData, IPathDrawer, IPathString, IBoundsData, ITwoPointBoundsData, IPointData, INumberMap, IStringMap } from '@leafer/interface'; | ||
| declare const PathCorner: { | ||
| smooth(data: IPathCommandData, _cornerRadius: number, _cornerSmoothing?: number): IPathCommandData; | ||
| smooth(data: IPathCommandData, cornerRadius: number, _cornerSmoothing?: number): IPathCommandData; | ||
| }; | ||
@@ -73,0 +73,0 @@ |
58327
4.06%1150
4.64%+ Added
+ Added
- Removed
- Removed
Updated
Updated