aboutsummaryrefslogtreecommitdiff
path: root/path/fillPrinter.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2020-12-23 19:11:31 +0100
committerSébastien Dailly <sebastien@chimrod.com>2020-12-23 19:11:31 +0100
commitec812521b31471ce9ac3d9bdf1288b1569defbc8 (patch)
treed384c959b9e9bb2a04141ab56077026fe6e7c7f3 /path/fillPrinter.ml
parent6354358caa1dfbf2fe1d481f6ac5fba3775938fc (diff)
Add svg output
Diffstat (limited to 'path/fillPrinter.ml')
-rwxr-xr-xpath/fillPrinter.ml121
1 files changed, 61 insertions, 60 deletions
diff --git a/path/fillPrinter.ml b/path/fillPrinter.ml
index d95030c..b506f9b 100755
--- a/path/fillPrinter.ml
+++ b/path/fillPrinter.ml
@@ -1,71 +1,72 @@
-module Repr = Layer.CanvaPrinter
+module Make(Repr: Layer.Repr.PRINTER) = struct
-type t = Point.t
+ type t = Point.t
-type 'a repr =
- { path: ('a Repr.t)
- ; close : 'a Repr.t -> unit
- }
-
-let create_path
- : 'b -> 'a repr
- = fun f ->
- { close = f
- ; path = Repr.create ()
+ type 'a repr =
+ { path: ('a Repr.t)
+ ; close : 'a Repr.t -> unit
}
-(* Start a new path. *)
-let start
- : Point.t -> 'a repr -> 'a repr
- = fun t {close ; path } ->
- let path = Repr.move_to (Point.get_coord t) path in
- { close
- ; path
- }
+ let create_path
+ : 'b -> 'a repr
+ = fun f ->
+ { close = f
+ ; path = Repr.create ()
+ }
+
+ (* Start a new path. *)
+ let start
+ : Point.t -> 'a repr -> 'a 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 -> 'a repr -> 'a 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 line_to
+ : Point.t -> Point.t -> 'a repr -> 'a 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 -> 'a repr -> 'a repr
- = fun p0 ctrl0 ctrl1 p1 t ->
+ let quadratic_to
+ : Point.t -> Gg.v2 -> Gg.v2 -> Point.t -> 'a repr -> 'a repr
+ = fun p0 ctrl0 ctrl1 p1 t ->
- let ctrl0' = Point.copy p1 ctrl0
- and ctrl1' = Point.copy p1 ctrl1 in
+ 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 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
- : 'a repr -> 'a repr
- = fun t ->
- t
+ let stop
+ : 'a repr -> 'a repr
+ = fun t ->
+ t
-let get
- : 'a repr -> 'a Repr.t
- = fun t ->
- t.path
+ let get
+ : 'a repr -> 'a Repr.t
+ = fun t ->
+ t.path
+end