From 06c39bbea3b7f8e6bfec88878ec80f9cc474184f Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 7 Jan 2021 00:03:03 +0100 Subject: Update --- script.it/selection.ml | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'script.it/selection.ml') diff --git a/script.it/selection.ml b/script.it/selection.ml index e05839b..c0360fb 100755 --- a/script.it/selection.ml +++ b/script.it/selection.ml @@ -29,44 +29,34 @@ let select_point = fun path v2_point -> let point' = ref None in + let dist = ref threshold in Path.Fixed.iter path ~f:(fun p -> let open Gg.V2 in - match (norm ((Path.Point.get_coord p) - v2_point) < threshold) with + let new_dist = norm ((Path.Point.get_coord p) - v2_point) in + match (new_dist < !dist) with | false -> () - | true -> point' := Some p + | true -> + dist:= new_dist; + point' := Some p ); match !point' with | Some point -> Point (Path.Fixed.id path, point) | None -> + Path (Path.Fixed.id path) + + (* (* If the point does not exists, find the exact point on the curve *) let coord = Gg.V2.to_tuple v2_point in begin match get_from_paths coord [path] with | _, None -> Path (Path.Fixed.id path) | f, Some (point, path, p0, p1) -> - let angle0 = Path.Point.get_angle p0 - and angle1 = Path.Point.get_angle p1 - and width0 = Path.Point.get_width p0 - and width1 = Path.Point.get_width p1 - and stamp0 = Path.Point.get_stamp p0 - and stamp1 = Path.Point.get_stamp p1 in - let angle = angle0 +. f *. ( angle1 -. angle0 ) in - let width = width0 +. f *. ( width1 -. width0 ) in - let stamp = stamp0 +. f *. ( stamp1 -. stamp0 ) in - - let x, y = Gg.V2.to_tuple point in - - let point' = Path.Point.create - ~angle - ~width - ~stamp - ~x - ~y - in + let point' = Path.Point.mix f point p0 p1 in Point (Path.Fixed.id path, point') end + *) -- cgit v1.2.3