blob: 45ee801aa8a136c69674f87d4cc7f51689f3264d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
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)
}
let create_path
: 'b -> repr
= fun _ ->
{ path = Repr.create ()
}
(* Start a new path. *)
let start
: Path.Point.t -> repr -> repr
= fun t {path} ->
let path = mark t path in
{ path
}
let line_to
: Path.Point.t -> Path.Point.t -> repr -> repr
= fun p0 p1 {path} ->
let path = Repr.move_to (Path.Point.get_coord p0) path
|> Repr.line_to (Path.Point.get_coord p1)
|> mark p1 in
{ path
}
let quadratic_to
: (t * Gg.v2 * Gg.v2 * t) -> repr -> repr
= fun (p0, ctrl0, ctrl1, p1) { path } ->
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 }
let stop
: repr -> repr
= fun path -> path
let get
: repr -> Repr.t
= fun {path; _} ->
path
end
|