diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-07 18:41:30 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-07 18:48:28 +0100 |
commit | 6e5c6bf7beadc72e64e5d929e301b473b01c9303 (patch) | |
tree | 02919ca31644a58d8b12e35c0072b38e8fab335a /script.it/state.ml | |
parent | 21c386fee208adb7b494d2677d9f49ed49a1c1ce (diff) |
Update
Diffstat (limited to 'script.it/state.ml')
-rwxr-xr-x | script.it/state.ml | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/script.it/state.ml b/script.it/state.ml index 585ca32..185be4f 100755 --- a/script.it/state.ml +++ b/script.it/state.ml @@ -111,8 +111,8 @@ let select_segment _ (_, selected, p0, p1) state dist = let point' = Path.Point.mix dist (Path.Point.get_coord p0) p0 p1 in - let angle = Path.Point.get_angle point' - and width = Path.Point.get_width point' in + let angle = (Float.round @@ 10. *. Path.Point.get_angle point') /. 10. + and width = (Float.round @@ 10. *. Path.Point.get_width point') /. 10. in let id = Selection.select_path selected in { state with @@ -175,8 +175,9 @@ let angle angle state = {state with paths } (* Change angle localy *) | Selection (Point (s, point)) -> - update_point_selection state s point - (fun p -> Path.Point.set_angle p angle) + let state = update_point_selection state s point + (fun p -> Path.Point.set_angle p angle) in + { state with angle } | _ -> { state with angle} @@ -187,8 +188,9 @@ let width width state = let paths = update_path_selection s state.paths (fun p -> Path.Point.set_width p width) in {state with paths } | Selection (Point (s, point)) -> - update_point_selection state s point - (fun p -> Path.Point.set_width p width) + let state = update_point_selection state s point + (fun p -> Path.Point.set_width p width) in + { state with width } | _ -> { state with width } @@ -239,10 +241,17 @@ let do_action else (* On the same segment, check for a point *) let selection = Selection.select_point path (Gg.V2.of_tuple position) in - - (* In order to handle the point move, start the timer *) - Elements.Timer.start timer 0.3; - {state with mode= Selection selection} + match selection with + | Path _ -> + { state with mode = Selection selection } + | Point (_, pt) -> + (* In order to handle the point move, start the timer *) + Elements.Timer.start timer 0.3; + { state with + mode = Selection selection + ; angle = Path.Point.get_angle pt + ; width = Path.Point.get_width pt + } end | `Out point, Edit -> @@ -344,7 +353,7 @@ let do_action match id = id' with | false -> path | true -> - Path.Fixed.update path paths + (Path.Fixed.update path paths) ) in { state with paths } |