-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1 @@ | ||
import { type IPoint } from '@suika/geo'; | ||
|
||
export type PathSegPointType = 'in' | 'out' | 'anchor'; | ||
|
||
export interface ISegment { | ||
point: IPoint; | ||
/** the coordinates relative to point */ | ||
in: IPoint; | ||
/** the coordinates relative to point */ | ||
out: IPoint; | ||
} | ||
|
||
export interface IPathItem { | ||
segs: ISegment[]; | ||
closed: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
packages/core/src/tools/tool_path_select/tool_path_select_move.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import fitCurve from 'fit-curve'; | ||
|
||
import { type ISegment } from '../type'; | ||
|
||
export const simplePath = (segs: ISegment[], tol: number) => { | ||
const curves = fitCurve( | ||
segs.map(({ point }) => [point.x, point.y]), | ||
tol, | ||
); | ||
const newSegs: ISegment[] = []; | ||
for (let i = 0, len = curves.length; i <= len; i++) { | ||
const curve = curves[i]; | ||
const prevCurve = curves[i - 1]; | ||
const point = curve | ||
? { | ||
x: curve[0][0], | ||
y: curve[0][1], | ||
} | ||
: { | ||
x: prevCurve[3][0], | ||
y: prevCurve[3][1], | ||
}; | ||
const outPt = curve | ||
? { | ||
x: curve[1][0] - point.x, | ||
y: curve[1][1] - point.y, | ||
} | ||
: { x: 0, y: 0 }; | ||
const inPt = prevCurve | ||
? { | ||
x: prevCurve[2][0] - point.x, | ||
y: prevCurve[2][1] - point.y, | ||
} | ||
: { x: 0, y: 0 }; | ||
newSegs.push({ | ||
point, | ||
in: inPt, | ||
out: outPt, | ||
}); | ||
} | ||
return newSegs; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.