diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-07 21:54:46 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-09 06:27:18 +0100 |
commit | 32618a5ce8e2b306af102e4c16711b090c36b840 (patch) | |
tree | 1c22b5bcf9f29e9ff0118cfa9aedd6fb05c9ab0f /script.it/script.ml | |
parent | 6e5c6bf7beadc72e64e5d929e301b473b01c9303 (diff) |
Allow point movement
Diffstat (limited to 'script.it/script.ml')
-rwxr-xr-x | script.it/script.ml | 15 |
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.) |