aboutsummaryrefslogtreecommitdiff
path: root/path/builder.mli
blob: 8c8081bdb77cf083ad387ce79d8f4f9b205ddd62 (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
(** Signature for points *)
module type P = sig
  type t

  val empty : t

  val get_coord : t -> Gg.v2

  (** Copy a point and all thoses properties to the given location *)
  val copy : t -> Gg.v2 -> t

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

  (** Create an empty path *)
  val empty: t

  val add_point
    : Point.t -> t -> t

  (** Replace the last alement in the path by the one given in parameter *)
  val replace_last
    : Point.t -> t -> t

  (** Retrieve the last element, if any *)
  val peek 
    : t -> Point.t option

  (** Retrieve the last element, if any *)
  val peek2
    : t -> (Point.t * Point.t) option

  (** Represent the path *)
  val repr
    : t -> (module REPR with type t = Point.t and type repr = 's) -> 's -> 's

end