aboutsummaryrefslogtreecommitdiff
path: root/script.it/state.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-09 11:35:40 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-09 11:35:40 +0100
commit329b774e315b41bc0d5b7daf8737222768c8d1f3 (patch)
tree94464c12dfa48d5fdb1508b9e8a115b4596d0e34 /script.it/state.ml
parentc734c1b30fd1c58a0d42020859be31d89b92bcd0 (diff)
Formalized exchanges between worker and app
Diffstat (limited to 'script.it/state.ml')
-rwxr-xr-xscript.it/state.ml14
1 files changed, 8 insertions, 6 deletions
diff --git a/script.it/state.ml b/script.it/state.ml
index da97b13..cc199d1 100755
--- a/script.it/state.ml
+++ b/script.it/state.ml
@@ -1,8 +1,6 @@
open StdLabels
open Brr
-let backgroundColor = Blog.Nord.nord0
-
type mode =
| Edit
| Selection of Selection.t
@@ -51,6 +49,10 @@ type state =
; rendering : Layer.Paths.printer
}
+let post
+ : Brr_webworkers.Worker.t -> Worker_messages.to_worker -> unit
+ = Brr_webworkers.Worker.post
+
let insert_or_replace state ((x, y) as p) stamp path =
let width = state.width
and angle = state.angle in
@@ -140,7 +142,7 @@ let delete state worker =
| false -> ()
| true ->
(* Send the job to the worker *)
- Brr_webworkers.Worker.post worker (`DeletePoint (point, p))
+ post worker (`DeletePoint (point, p))
);
{ state with mode = Selection (Path id) }
| _ ->
@@ -266,7 +268,7 @@ let do_action
current
in
- let () = Brr_webworkers.Worker.post worker (`Complete last) in
+ let () = post worker (`Complete last) in
last::state.paths
and current = Path.Path_Builder.empty in
@@ -302,7 +304,7 @@ let do_action
| false -> ()
| true ->
Option.iter
- (fun p -> Brr_webworkers.Worker.post worker (`Complete p))
+ (fun p -> post worker (`Complete p))
(Path.Fixed.replace_point path point')
);
@@ -322,7 +324,7 @@ let do_action
~f:(fun path ->
Layer.Paths.to_svg
- ~color:backgroundColor
+ ~color:Blog.Nord.nord0
(module Path.Fixed)
path
state.rendering