From 7bb561f31e0ee57a388032b760b7db943dd6b36c Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 1 Jan 2021 23:18:35 +0100 Subject: Update --- script.ml | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'script.ml') diff --git a/script.ml b/script.ml index d501b10..398e4f2 100755 --- a/script.ml +++ b/script.ml @@ -142,6 +142,18 @@ let set_sidebar ) ); + + let br = El.br () in + let render = + El.select + [ El.option ~at:At.[value (Jstr.v "Fill")] + [ txt' "Fill"] + ; El.option ~at:At.[value (Jstr.v "Wireframe")] + [ txt' "Wireframe"] + ; El.option ~at:At.[value (Jstr.v "Ductus")] + [ txt' "Ductus"] + ] in + let () = El.append_children element [ hr () @@ -155,6 +167,9 @@ let set_sidebar ; angle ; input_angle + ; br + ; render + ] in delete_event, angle_event, nib_size_event, export_event @@ -165,20 +180,20 @@ let green = Jstr.v "#a3be8c" (** Redraw the canva on update *) let on_change canva mouse_position state = - let open Brr_canvas.C2d in + let module Cd2d = Brr_canvas.C2d in let w, h = Brr_canvas.Canvas.(float_of_int @@ w canva, float_of_int @@ h canva) in - let context = create canva in + let context = Cd2d.create canva in - set_fill_style context (color backgroundColor); - fill_rect context + Cd2d.set_fill_style context (Cd2d.color backgroundColor); + Cd2d.fill_rect context ~x:0.0 ~y:0.0 ~w ~h; - set_stroke_style context (color white); - set_fill_style context (color white); + Cd2d.set_stroke_style context (Cd2d.color white); + Cd2d.set_fill_style context (Cd2d.color white); (* If we are in edit mode, we add a point under the cursor. @@ -197,28 +212,28 @@ let on_change canva mouse_position state = end in - let repr = `Wire in + let repr = `Fill in - Paths.to_canva (module Paths.Path_Builder) current context repr; + Path.to_canva (module Path.Path_Builder) current context repr; List.iter state.paths ~f:(fun path -> let () = match state.mode with | Selection id -> - begin match id = (Paths.Fixed.id path) with + begin match id = (Path.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) + Cd2d.set_fill_style context (Cd2d.color Blog.Nord.nord8); + Cd2d.set_stroke_style context (Cd2d.color Blog.Nord.nord8) | false -> - set_stroke_style context (color white); - set_fill_style context (color white); + Cd2d.set_stroke_style context (Cd2d.color white); + Cd2d.set_fill_style context (Cd2d.color white); end | _ -> () in - Paths.to_canva (module Paths.Fixed) path context repr + Path.to_canva (module Path.Fixed) path context repr ); () -- cgit v1.2.3