aboutsummaryrefslogtreecommitdiff
path: root/script.it/script.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-06 22:09:53 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-06 22:09:53 +0100
commita63662059215a26db627c4b76147a3c9338f5b74 (patch)
treec71b984b2327ebe743809e04b0a29aac0e15cc56 /script.it/script.ml
parent6ae97ecca8b4f38213f0f45aa6eaef944cd6b497 (diff)
Point suppression
Diffstat (limited to 'script.it/script.ml')
-rwxr-xr-xscript.it/script.ml42
1 files changed, 39 insertions, 3 deletions
diff --git a/script.it/script.ml b/script.it/script.ml
index 95272fb..e91dc92 100755
--- a/script.it/script.ml
+++ b/script.it/script.ml
@@ -144,7 +144,7 @@ let set_sidebar
El.select
[ El.option ~at:At.[value (Jstr.v "1")]
[ txt' "Fill"]
- ; El.option ~at:At.[value (Jstr.v "2")]
+ ; El.option ~at:At.[value (Jstr.v "3")]
[ txt' "Ductus"]
] in
@@ -212,7 +212,6 @@ let on_change canva mouse_position timer state =
Cd2d.set_stroke_style context (Cd2d.color white);
Cd2d.set_fill_style context (Cd2d.color white);
-
(* If we are in edit mode, we add a point under the cursor.
Otherwise, we would only display the previous registered point, which can
@@ -236,7 +235,8 @@ let on_change canva mouse_position timer state =
~f:(fun path ->
let () = match state.mode with
- | Selection id ->
+ | Selection (Path id)
+ | Selection (Point (id, _)) ->
begin match id = (Path.Fixed.id path) with
| true ->
(* If the element is the selected one, change the color *)
@@ -251,6 +251,42 @@ let on_change canva mouse_position timer state =
Layer.Paths.to_canva (module Path.Fixed) path context state.rendering
);
+
+ let () = match state.mode with
+ | Selection (Path id) ->
+ Cd2d.set_stroke_style context (Cd2d.color white);
+ List.iter
+ state.paths
+ ~f:(fun path ->
+ if id = Path.Fixed.id path then
+ Layer.Paths.to_canva (module Path.Fixed) path context `Line
+ )
+ | Selection (Point (id, point)) ->
+ (* As before, mark the selected path *)
+ Cd2d.set_stroke_style context (Cd2d.color white);
+ List.iter
+ state.paths
+ ~f:(fun path ->
+ if id = Path.Fixed.id path then
+ Layer.Paths.to_canva (module Path.Fixed) path context `Line
+ );
+
+ (* Now draw the selected point *)
+
+ let x, y = Gg.V2.to_tuple @@ Path.Point.get_coord point in
+ Cd2d.stroke_rect
+ ~x:(x -. 5.)
+ ~y:(y -. 5.)
+ ~w:10.
+ ~h:10.
+ context;
+
+
+
+ | _ -> ()
+ in
+
+
()
let spawn_worker () =