aboutsummaryrefslogtreecommitdiff
path: root/script.it/script.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-07 21:54:46 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-09 06:27:18 +0100
commit32618a5ce8e2b306af102e4c16711b090c36b840 (patch)
tree1c22b5bcf9f29e9ff0118cfa9aedd6fb05c9ab0f /script.it/script.ml
parent6e5c6bf7beadc72e64e5d929e301b473b01c9303 (diff)
Allow point movement
Diffstat (limited to 'script.it/script.ml')
-rwxr-xr-xscript.it/script.ml15
1 files changed, 14 insertions, 1 deletions
diff --git a/script.it/script.ml b/script.it/script.ml
index ede47be..ca831ba 100755
--- a/script.it/script.ml
+++ b/script.it/script.ml
@@ -264,15 +264,28 @@ let on_change canva mouse_position timer state =
| 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
+ let path = begin match pos with
+ | Some pos ->
+
+ let pos_v2 = Gg.V2.of_tuple pos in
+ if Elements.Timer.delay timer < 0.3 then
+ path
+ else
+ let point' = Path.Point.copy point pos_v2 in
+ begin match Path.Fixed.replace_point path point' with
+ | None -> path
+ | Some p -> p
+ end
+ | None -> path end in
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.)