-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve approximations for SVG export
- Loading branch information
Showing
6 changed files
with
120 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
"eslint": "^8.1.0", | ||
"lerna": "7.1.5", | ||
"prettier": "^2.4.1" | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha512.88c9c3864450350e65a33587ab801acf946d7c814ed1134da4a924f6df5a2120fd36b46aab68f7cd1d413149112d53c7db3a4136624cfd00ff1846a0c6cef48a" | ||
} |
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,28 @@ | ||
import { | ||
approximateAsSvgCompatibleCurve, | ||
ApproximationOptions, | ||
} from "../lib2d"; | ||
import Blueprint from "./Blueprint"; | ||
import Blueprints from "./Blueprints"; | ||
import { Shape2D } from "./boolean2D"; | ||
import CompoundBlueprint from "./CompoundBlueprint"; | ||
|
||
export function approximateForSVG<T extends Shape2D>( | ||
bp: T, | ||
options: ApproximationOptions | ||
): T { | ||
if (bp instanceof Blueprint) { | ||
return new Blueprint( | ||
approximateAsSvgCompatibleCurve(bp.curves, options) | ||
) as T; | ||
} else if (bp instanceof CompoundBlueprint) { | ||
return new CompoundBlueprint( | ||
bp.blueprints.map((b) => approximateForSVG(b, options)) | ||
) as T; | ||
} else if (bp instanceof Blueprints) { | ||
return new Blueprints( | ||
bp.blueprints.map((b) => approximateForSVG(b, options)) | ||
) as T; | ||
} | ||
return bp; | ||
} |
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