diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-01 16:48:23 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-01 16:48:23 +0100 |
commit | 74cd42c5cae6644914334448e198d562f4145511 (patch) | |
tree | d502e0798a04566c16d345c194ce725330631145 /path/linePrinter.ml | |
parent | af88c8895bba85fe5340b34aafb3dce7650bd01f (diff) |
Use first type module instead of functors pt.2
Diffstat (limited to 'path/linePrinter.ml')
-rwxr-xr-x | path/linePrinter.ml | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/path/linePrinter.ml b/path/linePrinter.ml index e109e4a..c0a7d58 100755 --- a/path/linePrinter.ml +++ b/path/linePrinter.ml @@ -1,53 +1,54 @@ -module Repr = Layer.CanvaPrinter +module Make(Repr: Layer.Repr.PRINTER) = struct -type t = Point.t + type t = Point.t -type repr = - { path: (Repr.t) - } - -let create_path - : 'b -> repr - = fun _ -> - { path = Repr.create () - } - -(* Start a new path. *) -let start - : Point.t -> repr -> repr - = fun t {path} -> - let path = Repr.move_to (Point.get_coord t) path in - let path = Repr.line_to (Point.get_coord' t) path in - { path - } - -let line_to - : Point.t -> Point.t -> repr -> repr - = fun _ t {path} -> - let path = Repr.move_to (Point.get_coord t) path in - let path = Repr.line_to (Point.get_coord' t) path in - { path - } - -let quadratic_to - : Point.t -> Gg.v2 -> Gg.v2 -> Point.t -> repr -> repr - = fun _p0 _ctrl0 _ctrl1 p1 {path} -> - - let path = Repr.move_to (Point.get_coord p1) path in - let path = Repr.line_to (Point.get_coord' p1) path in - - { path - } - -let stop - : repr -> repr - = fun {path} -> - - - { path + type repr = + { path: (Repr.t) } -let get - : repr -> Repr.t - = fun {path; _} -> - path + let create_path + : 'b -> repr + = fun _ -> + { path = Repr.create () + } + + (* Start a new path. *) + let start + : Point.t -> repr -> repr + = fun t {path} -> + let path = Repr.move_to (Point.get_coord t) path in + let path = Repr.line_to (Point.get_coord' t) path in + { path + } + + let line_to + : Point.t -> Point.t -> repr -> repr + = fun _ t {path} -> + let path = Repr.move_to (Point.get_coord t) path in + let path = Repr.line_to (Point.get_coord' t) path in + { path + } + + let quadratic_to + : Point.t -> Gg.v2 -> Gg.v2 -> Point.t -> repr -> repr + = fun _p0 _ctrl0 _ctrl1 p1 {path} -> + + let path = Repr.move_to (Point.get_coord p1) path in + let path = Repr.line_to (Point.get_coord' p1) path in + + { path + } + + let stop + : repr -> repr + = fun {path} -> + + + { path + } + + let get + : repr -> Repr.t + = fun {path; _} -> + path +end |