@@ -39,6 +39,8 @@ module Common = Viewer_common.F (struct
3939 let scale ctx ~sx ~sy = ctx##scale (sx, sy)
4040 let translate ctx ~tx ~ty = ctx##translate (tx, ty)
4141
42+ let set_line_width ctx w = ctx##lineWidth < - w
43+
4244 let begin_path ctx = ctx##beginPath ()
4345 let close_path ctx = ctx##closePath ()
4446 let move_to ctx ~x ~y = ctx##moveTo (x, y)
@@ -56,6 +58,7 @@ module Common = Viewer_common.F (struct
5658 let draw_text (ctx :ctx ) x y txt font fill_color stroke_color =
5759 ctx##font < - font;
5860 ctx##textAlign < - Js. string " center" ;
61+ ctx##textBaseline < - Js. string " middle" ;
5962 begin match fill_color with
6063 Some c -> ctx##fillStyle < - c; ctx##fillText (txt, x, y)
6164 | None -> ()
@@ -93,10 +96,7 @@ let redraw st s h v (canvas : Html.canvasElement Js.t) =
9396 let height = canvas##height in
9497(* Firebug.console##time (Js.string "draw");*)
9598 redraw st s h v canvas
96- {x = 0 ; y = 0 ; width = width; height = height} 0 0 width height;
97- begin try
98- ignore (canvas##getContext (Html. _2d_)##getImageData (0. , 0. , 1. , 1. ))
99- with _ -> () end
99+ {x = 0 ; y = 0 ; width = width; height = height} 0 0 width height
100100(*
101101;Firebug.console##timeEnd (Js.string "draw")
102102;Firebug.console##log_2 (Js.string "draw", Js.date##now())
@@ -245,6 +245,14 @@ Firebug.console##log_2(Js.string "update", Js.date##now());
245245 if vadj#value < 0. then vadj#set_value 0. ;
246246 if vadj#value > mv then vadj#set_value mv;
247247
248+ if not ! redraw_queued then begin
249+ redraw_queued := true ;
250+ Html. _requestAnimationFrame
251+ (Js. wrap_callback (fun () ->
252+ redraw_queued := false ;
253+ redraw st (get_scale () ) hadj#value vadj#value canvas))
254+ end
255+ (*
248256 if force then redraw st (get_scale ()) hadj#value vadj#value canvas else
249257 if not !redraw_queued then
250258 ignore (redraw_queued := true;
@@ -255,6 +263,7 @@ Firebug.console##log(Js.string "sleep");
255263 redraw_queued := false;
256264 redraw st (get_scale ()) hadj#value vadj#value canvas;
257265 Lwt.return ())
266+ *)
258267 in
259268
260269 let a = allocation () in
0 commit comments