-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(geom): add complexPolygonFromPath()
- Loading branch information
1 parent
83f3022
commit cd526f1
Showing
3 changed files
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Attribs, SamplingOpts } from "@thi.ng/geom-api"; | ||
import { ComplexPolygon } from "./api/complex-polygon.js"; | ||
import type { Path } from "./api/path.js"; | ||
import { asPolygon } from "./as-polygon.js"; | ||
|
||
/** | ||
* Converts given path into a {@link ComplexPolygon}, using `opts` to control | ||
* the conversion (via {@link asPolygon}). If no new `attribs` are given, those | ||
* of the path will be used (shallow copy). | ||
* | ||
* @param path | ||
* @param opts | ||
* @param attribs | ||
*/ | ||
export const complexPolygonFromPath = ( | ||
path: Path, | ||
opts?: number | Partial<SamplingOpts>, | ||
attribs?: Attribs | ||
) => { | ||
const [boundary, ...children] = asPolygon(path, opts); | ||
return new ComplexPolygon(boundary, children, attribs || boundary.attribs); | ||
}; |
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