summaryrefslogtreecommitdiff
path: root/path
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-09 11:35:40 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-09 11:35:40 +0100
commit329b774e315b41bc0d5b7daf8737222768c8d1f3 (patch)
tree94464c12dfa48d5fdb1508b9e8a115b4596d0e34 /path
parentc734c1b30fd1c58a0d42020859be31d89b92bcd0 (diff)
Formalized exchanges between worker and app
Diffstat (limited to 'path')
-rwxr-xr-xpath/builder.ml35
-rwxr-xr-xpath/fixed.ml24
-rwxr-xr-xpath/repr.ml2
3 files changed, 31 insertions, 30 deletions
diff --git a/path/builder.ml b/path/builder.ml
index fd772ea..7901e78 100755
--- a/path/builder.ml
+++ b/path/builder.ml
@@ -133,15 +133,15 @@ module Make(Point:P) = struct
Repr.start p0 path
|> Repr.quadratic_to
- p0'
- b0.Shapes.Bezier.ctrl0
- b0.Shapes.Bezier.ctrl1
- p1'
+ ( p0'
+ , b0.Shapes.Bezier.ctrl0
+ , b0.Shapes.Bezier.ctrl1
+ , p1' )
|> Repr.quadratic_to
- p1'
- b1.Shapes.Bezier.ctrl0
- b1.Shapes.Bezier.ctrl1
- p2'
+ ( p1'
+ , b1.Shapes.Bezier.ctrl0
+ , b1.Shapes.Bezier.ctrl1
+ , p2' )
| (p0::_ as points) ->
let (let*) v f =
@@ -179,10 +179,10 @@ module Make(Point:P) = struct
let bezier = Array.get beziers (i - 1) in
path := Repr.quadratic_to
- !point
- bezier.Shapes.Bezier.ctrl0
- bezier.Shapes.Bezier.ctrl1
- pt
+ ( !point
+ , bezier.Shapes.Bezier.ctrl0
+ , bezier.Shapes.Bezier.ctrl1
+ , pt )
(!path);
point := pt;
)
@@ -195,11 +195,12 @@ module Make(Point:P) = struct
Repr.stop @@ List.fold_left beziers
~init:path
~f:(fun path bezier ->
- let p0' = bezier.p0
- and ctrl0 = bezier.ctrl0
- and ctrl1 = bezier.ctrl1
- and p1' = bezier.p1 in
- Repr.quadratic_to p0' ctrl0 ctrl1 p1' path
+ Repr.quadratic_to
+ ( bezier.p0
+ , bezier.ctrl0
+ , bezier.ctrl1
+ , bezier.p1 )
+ path
)
end
diff --git a/path/fixed.ml b/path/fixed.ml
index 812dd3b..d9abcb5 100755
--- a/path/fixed.ml
+++ b/path/fixed.ml
@@ -14,6 +14,12 @@ end
module Make(Point:P) = struct
+ type bezier =
+ { p0:Point.t (* The starting point *)
+ ; p1:Point.t (* The end point *)
+ ; ctrl0:Gg.v2 (* The control point *)
+ ; ctrl1:Gg.v2 } (* The control point *)
+
module type BUILDER = sig
type t
@@ -21,12 +27,6 @@ module Make(Point:P) = struct
: t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's
end
- type bezier =
- { p0:Point.t (* The starting point *)
- ; p1:Point.t (* The end point *)
- ; ctrl0:Gg.v2 (* The control point *)
- ; ctrl1:Gg.v2 } (* The control point *)
-
type path =
| Line of Point.t * Point.t
| Curve of bezier
@@ -58,8 +58,8 @@ module Make(Point:P) = struct
, Line (p1, p2)::t)
let quadratic_to
- : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
- = fun p0 ctrl0 ctrl1 p1 (i, t) ->
+ : (t * Gg.v2 * Gg.v2 * t) -> repr -> repr
+ = fun (p0, ctrl0, ctrl1, p1) (i, t) ->
let curve = Curve
{ p0
; ctrl0
@@ -99,10 +99,10 @@ module Make(Point:P) = struct
= 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
- bezier.ctrl0
- bezier.ctrl1
- bezier.p1
+ ( bezier.p0
+ , bezier.ctrl0
+ , bezier.ctrl1
+ , bezier.p1 )
p in
let _, repr = Array.fold_left path
diff --git a/path/repr.ml b/path/repr.ml
index 63e7ba0..55a2920 100755
--- a/path/repr.ml
+++ b/path/repr.ml
@@ -11,7 +11,7 @@ module type M = sig
: t -> t -> repr -> repr
val quadratic_to
- : t -> Gg.v2 -> Gg.v2 -> t -> repr -> repr
+ : (t * Gg.v2 * Gg.v2 * t) -> repr -> repr
val stop
: repr -> repr