From 42c3c122c4f53dd68bcdd89411835887c3ae0af9 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 11 Jan 2021 11:33:32 +0100 Subject: Outline module --- script.it/selection.ml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'script.it/selection.ml') 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 *) -- cgit v1.2.3