earcut-ctfe 0.1.0
CTFE compatible D port (using GC) of the earcut polygon triangulation library.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
earcut-ctfe
Port of earcut-d that is available at CTFE, simply by using the GC and classes instead of malloc and pointers.
D port (betterC) of the earcut polygon triangulation library.
- ported from C++ port of a javascript library :D.
Quick example:
import earcut_ctfe;
import std.stdio;
import std.typecons;
alias Point = Tuple!(int, int);
static immutable Point[4][3] polygon = [
[Point(0, 0), Point(0, 200), Point(400, 200), Point(400, 0)], // boundary coords
[Point(50, 50), Point(50, 150), Point(150, 150), Point(150, 50)], // hole 1
[Point(250, 50), Point(250, 150), Point(300, 150), Point(300, 50)] // hole 2 ...
];
static immutable earcut = {
Earcut!(size_t, Point[4][3]) earcut;
earcut.run(polygon);
return earcut;
}();
void main()
{
// earcut.indices is of size_t[] (no runtime allocations at all if it's run at CTFE)
foreach (ref elem; earcut.indices)
writeln(elem);
}
- Registered by WebFreak
- 0.1.0 released 11 months ago
- WebFreak001/earcut-ctfe
- BSL-1.0
- Copyright © 2020-2024, Ferhat Kurtulmuş, Jan Jurzitza
- Authors:
- Dependencies:
- none
- Versions:
-
0.1.0 2024-Jan-06 ~master 2024-Jan-06 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
14 downloads total
-
- Score:
- 0.3
- Short URL:
- earcut-ctfe.dub.pm