aboutsummaryrefslogtreecommitdiff
path: root/layer/linePrinter.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-06 22:09:53 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-06 22:09:53 +0100
commita63662059215a26db627c4b76147a3c9338f5b74 (patch)
treec71b984b2327ebe743809e04b0a29aac0e15cc56 /layer/linePrinter.ml
parent6ae97ecca8b4f38213f0f45aa6eaef944cd6b497 (diff)
Point suppression
Diffstat (limited to 'layer/linePrinter.ml')
-rwxr-xr-xlayer/linePrinter.ml48
1 files changed, 22 insertions, 26 deletions
diff --git a/layer/linePrinter.ml b/layer/linePrinter.ml
index 3ed1c3c..c15bcc9 100755
--- a/layer/linePrinter.ml
+++ b/layer/linePrinter.ml
@@ -2,6 +2,21 @@ module Make(Repr: Repr.PRINTER) = struct
type t = Path.Point.t
+ let mark point path =
+ let open Gg.V2 in
+ let point = Path.Point.get_coord point in
+
+ let dist = 5.
+ and dist' = -5. in
+
+ let path = Repr.move_to (point - (of_tuple (dist, dist))) path
+ |> Repr.line_to ( point + (of_tuple (dist, dist)))
+ |> Repr.move_to (point + (of_tuple (dist', dist)))
+ |> Repr.line_to ( point + (of_tuple (dist, dist')))
+ in
+ path
+
+
type repr =
{ path: (Repr.t)
}
@@ -16,16 +31,15 @@ module Make(Repr: Repr.PRINTER) = struct
let start
: Path.Point.t -> repr -> repr
= fun t {path} ->
- let path = Repr.move_to (Path.Point.get_coord t) path in
- let path = Repr.line_to (Path.Point.get_coord' t) path in
+ let path = mark t path in
{ path
}
let line_to
: Path.Point.t -> Path.Point.t -> repr -> repr
= fun _ t {path} ->
- let path = Repr.move_to (Path.Point.get_coord t) path in
- let path = Repr.line_to (Path.Point.get_coord' t) path in
+ let path = Repr.line_to (Path.Point.get_coord t) path
+ |> mark t in
{ path
}
@@ -33,29 +47,11 @@ module Make(Repr: Repr.PRINTER) = struct
: Path.Point.t -> Gg.v2 -> Gg.v2 -> Path.Point.t -> repr -> repr
= fun p0 ctrl0 ctrl1 p1 { path } ->
- let path = ref path in
-
- let bezier =
- { Shapes.Bezier.p0 = Path.Point.get_coord p0
- ; ctrl0
- ; ctrl1
- ; p1 = Path.Point.get_coord p1
- } in
-
- (* Mark each point on the bezier curve. The first point is the most
- recent point *)
- let delay =
- ((Path.Point.get_stamp p0) -. (Path.Point.get_stamp p1))
- *. 100. /. 3.
- in
- for i = 0 to (Int.of_float delay) do
- let bezier', _ = Shapes.Bezier.slice (0.1 *. (Float.of_int i)) bezier in
- let point = Path.Point.copy p1 bezier'.Shapes.Bezier.p1 in
- path := Repr.move_to (Path.Point.get_coord point) !path;
- path := Repr.line_to (Path.Point.get_coord' point) !path;
- done;
+ let path = Repr.move_to (Path.Point.get_coord p0) path
+ |> Repr.quadratic_to ctrl0 ctrl1 (Path.Point.get_coord p1)
+ |> mark p1 in
- { path = !path }
+ { path = path }
let stop
: repr -> repr