aboutsummaryrefslogtreecommitdiff
path: root/path
diff options
context:
space:
mode:
Diffstat (limited to 'path')
-rwxr-xr-xpath/builder.ml23
-rwxr-xr-xpath/builder.mli21
-rwxr-xr-xpath/fillPrinter.ml10
-rwxr-xr-xpath/fixed.ml26
-rwxr-xr-xpath/fixed.mli24
-rwxr-xr-xpath/linePrinter.ml99
-rwxr-xr-xpath/repr.ml18
-rwxr-xr-xpath/wireFramePrinter.mli1
8 files changed, 82 insertions, 140 deletions
diff --git a/path/builder.ml b/path/builder.ml
index cb87fc5..182fc13 100755
--- a/path/builder.ml
+++ b/path/builder.ml
@@ -12,25 +12,6 @@ module type P = sig
end
-module type REPR = sig
- type t
-
- type repr
-
- (* Start a new path. *)
- val start
- : t -> repr -> repr
-
- val line_to
- : t -> t -> repr -> repr
-
- val quadratic_to
- : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
-
- val stop
- : repr -> repr
-end
-
module Make(Point:P) = struct
(** Point creation **)
@@ -123,8 +104,8 @@ module Make(Point:P) = struct
| hd::_ -> Some hd
let repr
- : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's
- = fun (type s) (points, beziers) (module Repr : REPR with type t = Point.t and type repr = s) path ->
+ : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
+ = fun (type s) (points, beziers) (module Repr : Repr.M with type t = Point.t and type repr = s) path ->
(* Represent the last points *)
let path = match points with
diff --git a/path/builder.mli b/path/builder.mli
index 8c8081b..78bb778 100755
--- a/path/builder.mli
+++ b/path/builder.mli
@@ -11,25 +11,6 @@ module type P = sig
end
-module type REPR = sig
- type t
-
- type repr
-
- (* Start a new path. *)
- val start
- : t -> repr -> repr
-
- val line_to
- : t -> t -> repr -> repr
-
- val quadratic_to
- : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
-
- val stop
- : repr -> repr
-end
-
module Make(Point:P) : sig
type t
@@ -54,6 +35,6 @@ module Make(Point:P) : sig
(** Represent the path *)
val repr
- : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's
+ : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
end
diff --git a/path/fillPrinter.ml b/path/fillPrinter.ml
index ab5a1eb..76056c7 100755
--- a/path/fillPrinter.ml
+++ b/path/fillPrinter.ml
@@ -3,12 +3,12 @@ module Make(Repr: Layer.Repr.PRINTER) = struct
type t = Point.t
type repr =
- { path: (Repr.t)
- ; close : Repr.t -> unit
+ { path: Repr.t
+ ; close : Repr.t -> Repr.t
}
let create_path
- : 'b -> repr
+ : (Repr.t -> Repr.t) -> repr
= fun f ->
{ close = f
; path = Repr.create ()
@@ -33,7 +33,7 @@ module Make(Repr: Layer.Repr.PRINTER) = struct
|> Repr.line_to (Point.get_coord p0)
|> Repr.line_to (Point.get_coord p1)
|> Repr.close in
- t.close path;
+ let path = t.close path in
{ t with path}
let quadratic_to
@@ -56,7 +56,7 @@ module Make(Repr: Layer.Repr.PRINTER) = struct
(Point.get_coord ctrl1')
(Point.get_coord p1)
|> Repr.close in
- t.close path;
+ let path = t.close path in
{ t with path}
diff --git a/path/fixed.ml b/path/fixed.ml
index 7203ebb..0ff4aad 100755
--- a/path/fixed.ml
+++ b/path/fixed.ml
@@ -13,33 +13,13 @@ module type P = sig
end
-module type REPR = sig
- type t
-
- type repr
-
- (* Start a new path. *)
- val start
- : t -> repr -> repr
-
- val line_to
- : t -> t -> repr -> repr
-
- val quadratic_to
- : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
-
- val stop
- : repr -> repr
-end
-
-
module Make(Point:P) = struct
module type BUILDER = sig
type t
val repr
- : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's
+ : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
end
type bezier =
@@ -113,8 +93,8 @@ module Make(Point:P) = struct
}
let repr
- : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's
- = fun (type s) {path; _} (module Repr : REPR with type t = Point.t and type repr = s) repr ->
+ : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
+ = fun (type s) {path; _} (module Repr : Repr.M with type t = Point.t and type repr = s) repr ->
let repr_bezier p bezier =
Repr.quadratic_to
bezier.p0
diff --git a/path/fixed.mli b/path/fixed.mli
index 3fc542c..1f02aed 100755
--- a/path/fixed.mli
+++ b/path/fixed.mli
@@ -11,33 +11,13 @@ module type P = sig
end
-module type REPR = sig
- type t
-
- type repr
-
- (* Start a new path. *)
- val start
- : t -> repr -> repr
-
- val line_to
- : t -> t -> repr -> repr
-
- val quadratic_to
- : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
-
- val stop
- : repr -> repr
-end
-
-
module Make(Point:P) : sig
module type BUILDER = sig
type t
val repr
- : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's
+ : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
end
@@ -53,7 +33,7 @@ module Make(Point:P) : sig
(** Represent the path *)
val repr
- : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's
+ : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
(** Return the distance between a given point and the curve. May return
None if the point is out of the curve *)
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
diff --git a/path/repr.ml b/path/repr.ml
new file mode 100755
index 0000000..63e7ba0
--- /dev/null
+++ b/path/repr.ml
@@ -0,0 +1,18 @@
+module type M = sig
+ type t
+
+ type repr
+
+ (* Start a new path. *)
+ val start
+ : t -> repr -> repr
+
+ val line_to
+ : t -> t -> repr -> repr
+
+ val quadratic_to
+ : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
+
+ val stop
+ : repr -> repr
+end
diff --git a/path/wireFramePrinter.mli b/path/wireFramePrinter.mli
index 1e76120..fa8a5a8 100755
--- a/path/wireFramePrinter.mli
+++ b/path/wireFramePrinter.mli
@@ -19,6 +19,7 @@ module Make(Repr:Layer.Repr.PRINTER): sig
val stop
: repr -> repr
+
val get
: repr -> Repr.t