From 32618a5ce8e2b306af102e4c16711b090c36b840 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 7 Jan 2021 21:54:46 +0100 Subject: Allow point movement --- script.it/script.ml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'script.it/script.ml') 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.) -- cgit v1.2.3