aboutsummaryrefslogtreecommitdiff
path: root/script.it/selection.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-11 11:33:32 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-11 13:55:43 +0100
commit42c3c122c4f53dd68bcdd89411835887c3ae0af9 (patch)
tree856a54955c4bf1648e7f5f1cea809e5601b60c7d /script.it/selection.ml
parent979be5f588a1ffd6e1d060cd794e87526d517b7a (diff)
Outline module
Diffstat (limited to 'script.it/selection.ml')
-rwxr-xr-xscript.it/selection.ml26
1 files changed, 13 insertions, 13 deletions
diff --git a/script.it/selection.ml b/script.it/selection.ml
index 591ea38..d00f026 100755
--- a/script.it/selection.ml
+++ b/script.it/selection.ml
@@ -7,32 +7,32 @@ type t =
let threshold = 20.
let get_from_paths
- : (float * float) -> Path.Fixed.t list -> float * (Gg.v2 * Path.Fixed.t * Path.Point.t * Path.Point.t) option
- = fun position paths ->
+ : (float * float) -> Outline.t list -> float * (Gg.v2 * Outline.t * Path.Point.t * Path.Point.t) option
+ = fun position outlines ->
let point = Gg.V2.of_tuple position in
(* If the user click on a curve, select it *)
- List.fold_left paths
+ List.fold_left outlines
~init:(threshold, None)
- ~f:(fun (dist, selection) path ->
- match Path.Fixed.distance point path with
+ ~f:(fun (dist, selection) outline ->
+ match Path.Fixed.distance point outline.Outline.path with
| Some { closest_point ; distance; p0; p1 ; ratio} when distance < dist ->
- ratio, Some (closest_point, path, p0, p1)
+ ratio, Some (closest_point, outline, p0, p1)
| _ -> dist, selection
)
let select_path
- : Path.Fixed.t -> t
- = fun path -> Path (Path.Fixed.id path)
+ : Outline.t -> t
+ = fun outline -> Path outline.Outline.id
let select_point
- : Path.Fixed.t -> Gg.v2 -> t
- = fun path v2_point ->
+ : Outline.t -> Gg.v2 -> t
+ = fun outline v2_point ->
let point' = ref None in
let dist = ref threshold in
Path.Fixed.iter
- path
+ outline.Outline.path
~f:(fun p ->
let open Gg.V2 in
let new_dist = norm ((Path.Point.get_coord p) - v2_point) in
@@ -45,9 +45,9 @@ let select_point
match !point' with
| Some point ->
- Point (Path.Fixed.id path, point)
+ Point (outline.Outline.id, point)
| None ->
- Path (Path.Fixed.id path)
+ Path (outline.Outline.id)
(*
(* If the point does not exists, find the exact point on the curve *)