aboutsummaryrefslogtreecommitdiff
path: root/script.it/selection.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-05-24 22:13:19 +0200
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:22:43 +0100
commit38cf58ac5e1adb38a1b99ea7cdda19ef7b5e12bf (patch)
tree4f94bff126e1dff186e0dafe5fca86657233acb1 /script.it/selection.ml
parent1a53943340d068a1dbcef2f006e44905bab47bff (diff)
Refactor
Diffstat (limited to 'script.it/selection.ml')
-rwxr-xr-xscript.it/selection.ml71
1 files changed, 0 insertions, 71 deletions
diff --git a/script.it/selection.ml b/script.it/selection.ml
deleted file mode 100755
index f5f135a..0000000
--- a/script.it/selection.ml
+++ /dev/null
@@ -1,71 +0,0 @@
-open StdLabels
-
-type 'a selection =
- | Path of 'a
- | Point of ('a * Path.Point.t)
-
-type t = int selection
-
-let find_selection
- : int selection -> Outline.t list -> Outline.t selection option
- = fun selection paths ->
- match selection with
- | Path id -> Option.map (fun p -> Path p) (Outline.find paths id)
- | Point (id, pt) -> Option.map (fun p -> Point (p, pt)) (Outline.find paths id)
-
-let threshold = 20.
-
-let get_from_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 outlines
- ~init:(threshold, None)
- ~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, outline, p0, p1)
- | _ -> dist, selection
- )
-
-let select_path
- : Outline.t -> t
- = fun outline -> Path outline.Outline.id
-
-let select_point
- : Outline.t -> Gg.v2 -> t
- = fun outline v2_point ->
-
- let point' = ref None in
- let dist = ref threshold in
-
- Path.Fixed.iter
- outline.Outline.path
- ~f:(fun p ->
- let open Gg.V2 in
- let new_dist = norm ((Path.Point.get_coord p) - v2_point) in
- match (new_dist < !dist) with
- | false -> ()
- | true ->
- dist:= new_dist;
- point' := Some p
- );
-
- match !point' with
- | Some point ->
- Point (outline.Outline.id, point)
- | None ->
- Path (outline.Outline.id)
-
- (*
- (* 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 point' = Path.Point.mix f point p0 p1 in
- Point (Path.Fixed.id path, point')
- end
- *)