Clipper

Clipper provides OCaml bindings to the Clipper2 polygon clipping (C++) library.

API

Clipper -- top level library interface

Functor Parameters

Functors

Each functor produces instances that adhere to the signature S. The D variants take a 2d float vector type in V, and create bindings to the decimal interface of Clipper2, while the 64 variants do the same but for the int64 interface.

Example

module C = Clipper.MakeD (struct
    type t = float * float
    let v x y = x, y
    let x t = fst t
    let y t = snd t
  end)
  ((val Clipper.config ~fill_rule:`EvenOdd ()))
let ex =
  let a = [ 0., 0.; 10., 0.; 10., 10.; 0., 10. ] in
  let b = List.map (fun (x, y) -> x +. 5., y +. 5.) a in
  C.(contour @@ difference (path a) ([ path b ]))

Sub-libraries

In addition to the the higher level abstraction provided by the main library, the sub-librarys clipper.c and clipper.clpr are provided to enable lower-level access to the underlying C API.