aboutsummaryrefslogtreecommitdiff
path: root/path/fixed.mli
blob: 06b3539283cdca5d390aab96353c87a88ed7b825 (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
67
68
69
70
(** Signature for points *)
module type P = sig
  type t

  val get_coord : t -> Gg.v2

  val id : t -> int

end

module Make(Point:P) : sig

  module type BUILDER = sig
    type t

    val repr
      : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's

  end

  type t 

  (** Return the identifier for this path *)
  val id
    : t -> int

  (** Create a path from a builder *)
  val to_fixed
    : (module BUILDER with type t = 'a) -> 'a -> t

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

  type approx =
    { distance : float
    ; closest_point : Gg.v2
    ; ratio : float
    ; p0 : Point.t
    ; p1 : Point.t }

  (** Return the distance between a given point and the curve. May return
      None if the point is out of the curve *)
  val distance
    : Gg.v2 -> t -> approx option

  val iter
    : t -> f:(Point.t -> unit) -> unit

  val map_point
    : t -> (Point.t -> Point.t) -> t

  val remove_point 
    : t -> Point.t -> t

  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

  val path : t -> path array

  val update : t -> path array -> t

end