-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: update line2cubic algorithm #102 * chore: bump version
- Loading branch information
Showing
8 changed files
with
26 additions
and
46 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
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,22 +1,7 @@ | ||
import { segmentLineFactory } from '../util/segment-line-factory'; | ||
import { midPoint } from '../util/mid-point'; | ||
|
||
export function lineToCubic(x1: number, y1: number, x2: number, y2: number) { | ||
export const lineToCubic = (x1: number, y1: number, x2: number, y2: number) => { | ||
const t = 0.5; | ||
const p0 = [x1, y1]; | ||
const p1 = [x2, y2]; | ||
const p2 = midPoint(p0, p1, t); | ||
const p3 = midPoint(p1, p2, t); | ||
const p4 = midPoint(p2, p3, t); | ||
const p5 = midPoint(p3, p4, t); | ||
const p6 = midPoint(p4, p5, t); | ||
|
||
// const seg1 = [...p0, ...p2, ...p4, ...p6, t]; | ||
// @ts-ignore | ||
const cp1 = segmentLineFactory(p0[0], p0[1], p2[0], p2[1], p4[0]).point; | ||
// const seg2 = [...p6, ...p5, ...p3, ...p1, 0]; | ||
// @ts-ignore | ||
const cp2 = segmentLineFactory(p6[0], p6[1], p5[0], p5[1], p3[0]).point; | ||
|
||
return [cp1.x, cp1.y, cp2.x, cp2.y, x2, y2]; | ||
} | ||
const mid = midPoint([x1, y1], [x2, y2], t); | ||
return [...mid, x2, y2, x2, y2]; | ||
}; |
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