aboutsummaryrefslogtreecommitdiff
path: root/script.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2020-12-30 11:41:01 +0100
committerSébastien Dailly <sebastien@chimrod.com>2020-12-30 11:41:01 +0100
commite25b7797708c19cbaef68c14ebef8738de44c2d9 (patch)
tree6d778a7bca390c496ee95cfb337f2f26fe0aa5c3 /script.ml
parentfae31bdb659b4b14322136e045ea565d38bbd04f (diff)
Refactor
Diffstat (limited to 'script.ml')
-rwxr-xr-xscript.ml31
1 files changed, 12 insertions, 19 deletions
diff --git a/script.ml b/script.ml
index a250c7f..d7d969c 100755
--- a/script.ml
+++ b/script.ml
@@ -3,12 +3,9 @@ open Note
open Brr
open Brr_note
-module CanvaRepr = Path.FillPrinter.Make(Layer.CanvaPrinter)
-module Path_Printer = Paths.Path_Builder.Draw(CanvaRepr)
-module Fixed_Printer = Paths.Path_Builder.DrawFixed(CanvaRepr)
-
-type canva_signal = Path.Point.t
+module Path_Printer = Paths.Path_Builder.Draw(Paths.CanvaRepr)
+module Fixed_Printer = Paths.Fixed.DrawFixed(Paths.CanvaRepr)
module Mouse = Brr_note_kit.Mouse
@@ -195,32 +192,29 @@ let on_change canva mouse_position state =
*)
let pos = S.rough_value mouse_position in
- let current, paths =
+ let current =
begin match state.State.mode, pos with
| Edit, Some point ->
- begin match State.insert_or_replace state point state.current with
- | current, None -> current, state.paths
- | current, Some p -> current, p::state.paths
- end
+ State.insert_or_replace state point state.current
| _ ->
- state.current, state.paths
+ state.current
end
in
- let path = CanvaRepr.get
+ let path = Paths.CanvaRepr.get
@@ Path_Printer.draw
current
- (* (CanvaRepr.create_path (fun p -> fill context p)) in *)
- (CanvaRepr.create_path (fun _ -> () )) in
+ (Paths.CanvaRepr.create_path (fun p -> fill context p)) in
stroke context path;
- List.iter paths
+ List.iter state.paths
~f:(fun path ->
let () = match state.mode with
| Selection s ->
- begin match (Paths.Path_Builder.id s) = (Paths.Path_Builder.id path) with
+ begin match (Paths.Fixed.id s) = (Paths.Fixed.id path) with
| true ->
+ (* If the element is the selected one, change the color *)
set_fill_style context (color Blog.Nord.nord8);
set_stroke_style context (color Blog.Nord.nord8)
| false ->
@@ -230,10 +224,10 @@ let on_change canva mouse_position state =
| _ -> ()
in
- let path = CanvaRepr.get
+ let path = Paths.CanvaRepr.get
@@ Fixed_Printer.draw
path
- (CanvaRepr.create_path (fun p -> fill context p)) in
+ (Paths.CanvaRepr.create_path (fun p -> fill context p)) in
stroke context path;
);
()
@@ -241,7 +235,6 @@ let on_change canva mouse_position state =
let page_main id =
-
let delete_event', angle_signal', width_signal', export_event' =
begin match Blog.Sidebar.get () with
| None ->