module Make(Repr: Layer.Repr.PRINTER) = struct type t = Point.t type repr = { path: (Repr.t) ; close : Repr.t -> unit } let create_path : 'b -> repr = fun f -> { close = f ; path = Repr.create () } (* Start a new path. *) let start : Point.t -> repr -> repr = fun t {close ; path } -> let path = Repr.move_to (Point.get_coord t) path in { close ; path } let line_to : Point.t -> Point.t -> repr -> repr = fun p0 p1 t -> let path = Repr.move_to (Point.get_coord p1) t.path |> Repr.line_to (Point.get_coord' p1) |> Repr.line_to (Point.get_coord' p0) |> Repr.line_to (Point.get_coord p0) |> Repr.line_to (Point.get_coord p1) |> Repr.close in t.close path; { t with path} let quadratic_to : Point.t -> Gg.v2 -> Gg.v2 -> Point.t -> repr -> repr = fun p0 ctrl0 ctrl1 p1 t -> let ctrl0' = Point.copy p1 ctrl0 and ctrl1' = Point.copy p1 ctrl1 in let path = Repr.move_to (Point.get_coord p1) t.path |> Repr.line_to (Point.get_coord' p1) |> Repr.quadratic_to (Point.get_coord' ctrl1') (Point.get_coord' ctrl0') (Point.get_coord' p0) |> Repr.line_to (Point.get_coord p0) |> Repr.quadratic_to (Point.get_coord ctrl0') (Point.get_coord ctrl1') (Point.get_coord p1) |> Repr.close in t.close path; { t with path} let stop : repr -> repr = fun t -> t let get : repr -> Repr.t = fun t -> t.path end