aboutsummaryrefslogtreecommitdiff
path: root/script.it/selection.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-07 00:03:03 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-07 00:03:03 +0100
commit06c39bbea3b7f8e6bfec88878ec80f9cc474184f (patch)
tree6394250ec5795f9b718595cf409b49517ab98759 /script.it/selection.ml
parenta63662059215a26db627c4b76147a3c9338f5b74 (diff)
Update
Diffstat (limited to 'script.it/selection.ml')
-rwxr-xr-xscript.it/selection.ml32
1 files changed, 11 insertions, 21 deletions
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
+ *)