A port of Clipper2: polygon union, intersection, difference, xor and offsetting, with results identical to the C++ library
moon add t-ujiie-g/clipperfn square(x : Int64, y : Int64, s : Int64) -> Array[@clipper.Point64] {
[{ x, y }, { x: x + s, y }, { x: x + s, y: y + s }, { x, y: y + s }]
}
test "clip and offset" {
let a = [square(0L, 0L, 10L)]
let b = [square(5L, 5L, 10L)]
let both = @clipper.intersect(a, b, NonZero)
assert_eq(@clipper.area(both[0][:]), 25.0)
let either = @clipper.union(a, b, NonZero)
assert_eq(@clipper.area(either[0][:]), 175.0)
// A square grown by 1 with miter joins keeps its corners: 12 x 12.
let grown = @clipper.inflate_paths(a, 1.0, Miter, Polygon)
assert_eq(@clipper.area(grown[0][:]), 144.0)
}pub struct Clipper64 {
// private fields
}pub struct ClipperOffset {
// private fields
}fn ClipperOffset::add_paths(self : ClipperOffset, paths : Array[Array[Point64]], join_type : JoinType, end_type : EndType) -> Unitfn ClipperOffset::new(miter_limit? : Double, arc_tolerance? : Double, preserve_collinear? : Bool, reverse_solution? : Bool) -> ClipperOffsetInstall
Download zipA port of Clipper2: polygon union, intersection, difference, xor and offsetting, with results identical to the C++ library