Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ocp-jslib: add Graphics module

Not yet working properly :-(
  • Loading branch information...
commit 6ca911ad76ee5a1c12fc64b82cd5c64670ec61a0 1 parent 0dd3d71
Fabrice Le Fessant authored
View
2  ocp-jslib/Makefile
@@ -3,7 +3,7 @@ ROOT=..
include $(ROOT)/Makefile.config
include $(ROOT)/Makefile.jsconfig
-MLOBJS= utils.cmo button.cmo cookie.cmo dragnDrop.cmo
+MLOBJS= utils.cmo button.cmo cookie.cmo dragnDrop.cmo graphics.cmo
MLINTFS= $(MLOBJS:.cmo=.cmi)
INCLUDES= -I $(JS_DIR)/lib
View
378 ocp-jslib/graphics.ml
@@ -0,0 +1,378 @@
+
+exception Graphic_failure of string
+
+open Utils
+(*
+val open_graph : (string -> unit)
+*)
+
+type state = {
+ context : Dom_html.canvasRenderingContext2D Js.t;
+ mutable x : int;
+ mutable y : int;
+ mutable width : int;
+ mutable height : int;
+ mutable color : int;
+ mutable line_width : int;
+ mutable text_size : int;
+ mutable font : string;
+}
+
+let state = ref None
+
+let get_state () =
+ match !state with
+ None -> raise (Graphic_failure "Not initialized")
+ | Some s -> s
+
+let raw_set_color s =
+(* TODO : do better ! *)
+ s.context##fillStyle <- Js.string
+ (Printf.sprintf "#%02x%02x%02x"
+ ( (s.color lsr 16) land 0xff )
+ ( (s.color lsr 8) land 0xff )
+ ( (s.color lsr 0) land 0xff )
+ )
+
+
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the GNU Library General Public License, with *)
+(* the special exception on linking described in file ../../LICENSE. *)
+(* *)
+(***********************************************************************)
+
+(* Initializations *)
+
+let _ =
+ Callback.register_exception "Graphics.Graphic_failure" (Graphic_failure "")
+
+let set_window_title title =
+ (* TODO *) ()
+let resize_window width height =
+ (* TODO *) ()
+let clear_graph () =
+ (* TODO *) ()
+let size_x () =
+ let s = get_state () in
+ s.width
+
+let size_y () =
+ let s = get_state () in
+ s.height
+
+(* Double-buffering *)
+
+let display_mode bool =
+ (* TODO *) ()
+let remember_mode bool =
+ (* TODO *) ()
+let synchronize unit =
+ (* TODO *) ()
+
+let auto_synchronize = function
+ | true -> display_mode true; remember_mode true; synchronize ()
+ | false -> display_mode false; remember_mode true
+;;
+
+
+(* Colors *)
+
+type color = int
+
+let rgb r g b = (r lsl 16) + (g lsl 8) + b
+
+let set_color color =
+ let s = get_state () in
+ s.color <- color
+
+let black = 0x000000
+and white = 0xFFFFFF
+and red = 0xFF0000
+and green = 0x00FF00
+and blue = 0x0000FF
+and yellow = 0xFFFF00
+and cyan = 0x00FFFF
+and magenta = 0xFF00FF
+
+let background = white
+and foreground = black
+
+(* Drawing *)
+
+let plot x y =
+ let s = get_state () in
+ s.x <- x;
+ s.y <- y;
+ raw_set_color s;
+ let context = s.context in
+ context##moveTo (float x, float (s.height - y));
+ context##lineTo (float x, float (s.height - y))
+
+let plots points =
+ for i = 0 to Array.length points - 1 do
+ let (x, y) = points.(i) in
+ plot x y;
+ done
+;;
+
+let point_color x y =
+ failwith "Graphics.point_color not implemented"
+
+let moveto x y =
+ let s = get_state () in
+ s.x <- x;
+ s.y <- y
+
+let current_x () =
+ let s = get_state () in
+ s.x
+let current_y () =
+ let s = get_state () in
+ s.y
+
+let current_point () = current_x (), current_y ()
+let lineto x y =
+ let s = get_state () in
+ raw_set_color s;
+ let context = s.context in
+ context##moveTo (float s.x, float (s.height - s.y));
+ context##lineTo (float x, float (s.height - y));
+ s.x <- x;
+ s.y <- y;
+ ()
+
+
+let rlineto x y = lineto (current_x () + x) (current_y () + y)
+let rmoveto x y = moveto (current_x () + x) (current_y () + y)
+
+let raw_draw_rect x y dx dy =
+ let s = get_state () in
+ raw_set_color s;
+ s.context##strokeRect (float x, float (s.height - y), float dx, float dy)
+
+let draw_rect x y w h =
+ if w < 0 || h < 0 then raise (Invalid_argument "draw_rect")
+ else raw_draw_rect x y w h
+;;
+
+let draw_poly, draw_poly_line =
+ let dodraw close_flag points =
+ if Array.length points > 0 then begin
+ let (savex, savey) = current_point () in
+ moveto (fst points.(0)) (snd points.(0));
+ for i = 1 to Array.length points - 1 do
+ let (x, y) = points.(i) in
+ lineto x y;
+ done;
+ if close_flag then lineto (fst points.(0)) (snd points.(0));
+ moveto savex savey;
+ end;
+ in dodraw true, dodraw false
+;;
+let draw_segments segs =
+ let (savex, savey) = current_point () in
+ for i = 0 to Array.length segs - 1 do
+ let (x1, y1, x2, y2) = segs.(i) in
+ moveto x1 y1;
+ lineto x2 y2;
+ done;
+ moveto savex savey;
+;;
+let raw_draw_arc x y rx ry a1 a2 =
+ failwith "Graphics.raw_draw_arc not implemented"
+
+let draw_arc x y rx ry a1 a2 =
+ if rx < 0 || ry < 0 then raise (Invalid_argument "draw_arc/ellipse/circle")
+ else raw_draw_arc x y rx ry a1 a2
+;;
+
+let draw_ellipse x y rx ry = draw_arc x y rx ry 0 360
+let draw_circle x y r = draw_arc x y r r 0 360
+
+let raw_set_line_width w =
+ let s = get_state () in
+ s.line_width <- w
+
+let set_line_width w =
+ if w < 0 then raise (Invalid_argument "set_line_width")
+ else raw_set_line_width w
+;;
+
+let raw_fill_rect x y dx dy =
+ let s = get_state () in
+ raw_set_color s;
+ s.context##fillRect (float x, float (s.height - y), float dx, float dy)
+
+let fill_rect x y w h =
+ if w < 0 || h < 0 then raise (Invalid_argument "fill_rect")
+ else raw_fill_rect x y w h
+;;
+
+let fill_poly point_array =
+ failwith "Graphics.fill_poly not implemented"
+let raw_fill_arc x y rx ry a1 a2 =
+ failwith "Graphics.raw_fill_arc not implemented"
+
+let fill_arc x y rx ry a1 a2 =
+ if rx < 0 || ry < 0 then raise (Invalid_argument "fill_arc/ellipse/circle")
+ else raw_fill_arc x y rx ry a1 a2
+;;
+
+let fill_ellipse x y rx ry = fill_arc x y rx ry 0 360
+let fill_circle x y r = fill_arc x y r r 0 360
+
+(* Text *)
+
+
+let draw_string cs =
+ let s = get_state () in
+ let sdx = s.text_size * String.length cs in
+ s.context##strokeText_withWidth
+ (Js.string cs, float s.x, float (s.height - s.y), float sdx);
+ s.x <- s.x + sdx
+
+(*
+ let m = s.context##measureText (Js.string cs) in
+ let dx = m##width in (* TODO check !!! *)
+*)
+let draw_char c =
+ let cs = String.make 1 c in draw_string cs
+
+let set_font f =
+ let s = get_state () in
+ s.font <- f
+
+let set_text_size sz =
+ let s = get_state () in
+ s.text_size <- sz
+
+let text_size cs =
+ let s = get_state () in
+ let m = s.context##measureText (Js.string cs) in
+ let dx = m##width in (* TODO check !!! *)
+ (int_of_float dx, 10) (* TODO: fix height ? *)
+
+(* Images *)
+
+type image
+
+let transp = -1
+
+let make_image img = failwith "Graphics.make_image not implemented"
+let dump_image img = failwith "Graphics.dump_image not implemented"
+let draw_image img x y = failwith "Graphics.draw_image not implemented"
+let create_image dx dy = failwith "Graphics.create_image not implemented"
+let blit_image img x y = failwith "Graphics.blit_image not implemented"
+
+let get_image x y w h =
+ let image = create_image w h in
+ blit_image image x y;
+ image
+
+(* Events *)
+
+type status =
+ { mouse_x : int;
+ mouse_y : int;
+ button : bool;
+ keypressed : bool;
+ key : char }
+
+type event =
+ Button_down
+ | Button_up
+ | Key_pressed
+ | Mouse_motion
+ | Poll
+
+(*external wait_next_event : event list -> status = "caml_gr_wait_event" *)
+let wait_next_event elist =
+ failwith "Graphics.wait_next_event cannot be implemented"
+
+let mouse_pos () =
+ let e = wait_next_event [Poll] in (e.mouse_x, e.mouse_y)
+
+let button_down () =
+ let e = wait_next_event [Poll] in e.button
+
+let read_key () =
+ let e = wait_next_event [Key_pressed] in e.key
+
+let key_pressed () =
+ let e = wait_next_event [Poll] in e.keypressed
+
+(*** Sound *)
+
+let sound _ _ =
+ failwith "Graphics.sound not implemented"
+
+(* Splines *)
+let add (x1, y1) (x2, y2) = (x1 +. x2, y1 +. y2)
+and sub (x1, y1) (x2, y2) = (x1 -. x2, y1 -. y2)
+and middle (x1, y1) (x2, y2) = ((x1 +. x2) /. 2.0, (y1 +. y2) /. 2.0)
+and area (x1, y1) (x2, y2) = abs_float (x1 *. y2 -. x2 *. y1)
+and norm (x1, y1) = sqrt (x1 *. x1 +. y1 *. y1);;
+
+let test a b c d =
+ let v = sub d a in
+ let s = norm v in
+ area v (sub a b) <= s && area v (sub a c) <= s;;
+
+let spline a b c d =
+ let rec spl accu a b c d =
+ if test a b c d then d :: accu else
+ let a' = middle a b
+ and o = middle b c in
+ let b' = middle a' o
+ and d' = middle c d in
+ let c' = middle o d' in
+ let i = middle b' c' in
+ spl (spl accu a a' b' i) i c' d' d in
+ spl [a] a b c d;;
+
+let curveto b c (x, y as d) =
+ let float_point (x, y) = (float_of_int x, float_of_int y) in
+ let round f = int_of_float (f +. 0.5) in
+ let int_point (x, y) = (round x, round y) in
+ let points =
+ spline
+ (float_point (current_point ()))
+ (float_point b) (float_point c) (float_point d) in
+ draw_poly_line
+ (Array.of_list (List.map int_point points));
+ moveto x y;;
+
+
+(*
+val close_graph : (unit -> unit)
+*)
+let close_graph () =
+ match !state with
+ None -> ()
+ | Some c ->
+ state := None;
+ Utils.set_div_by_id "graphics" ""
+
+let open_graph string =
+ close_graph ();
+ let canvas = Dom_html.createCanvas doc in
+ let body = Utils.get_element_by_id "graphics" in
+ let context = canvas##getContext (Dom_html._2d_) in
+ Dom.appendChild body canvas;
+ let x = 0 in
+ let y = 0 in
+ let width = 400 in
+ let height = 400 in
+ let color = blue in
+ let line_width = 1 in
+ let font = "fixed" in
+ let text_size = 26 in
+ state := Some { context; x; y; width; height; color;
+ line_width; font; text_size }
View
377 ocp-jslib/graphics.mli
@@ -0,0 +1,377 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the GNU Library General Public License, with *)
+(* the special exception on linking described in file ../../LICENSE. *)
+(* *)
+(***********************************************************************)
+
+(* $Id: graphics.mli 11156 2011-07-27 14:17:02Z doligez $ *)
+
+(** Machine-independent graphics primitives. *)
+
+exception Graphic_failure of string
+(** Raised by the functions below when they encounter an error. *)
+
+
+(** {6 Initializations} *)
+
+val open_graph : string -> unit
+(** Show the graphics window or switch the screen to graphic mode.
+ The graphics window is cleared and the current point is set
+ to (0, 0). The string argument is used to pass optional
+ information on the desired graphics mode, the graphics window
+ size, and so on. Its interpretation is implementation-dependent.
+ If the empty string is given, a sensible default is selected. *)
+
+val close_graph : unit -> unit
+(** Delete the graphics window or switch the screen back to text mode. *)
+
+val set_window_title : string -> unit
+(** Set the title of the graphics window. *)
+
+val resize_window : int -> int -> unit
+(** Resize and erase the graphics window. *)
+
+val clear_graph : unit -> unit
+(** Erase the graphics window. *)
+
+val size_x : unit -> int
+(** See {!Graphics.size_y}. *)
+
+val size_y : unit -> int
+(** Return the size of the graphics window. Coordinates of the screen
+ pixels range over [0 .. size_x()-1] and [0 .. size_y()-1].
+ Drawings outside of this rectangle are clipped, without causing
+ an error. The origin (0,0) is at the lower left corner. *)
+
+(** {6 Colors} *)
+
+type color = int
+(** A color is specified by its R, G, B components. Each component
+ is in the range [0..255]. The three components are packed in
+ an [int]: [0xRRGGBB], where [RR] are the two hexadecimal digits for
+ the red component, [GG] for the green component, [BB] for the
+ blue component. *)
+
+val rgb : int -> int -> int -> color
+(** [rgb r g b] returns the integer encoding the color with red
+ component [r], green component [g], and blue component [b].
+ [r], [g] and [b] are in the range [0..255]. *)
+
+val set_color : color -> unit
+(** Set the current drawing color. *)
+
+val background : color
+(** See {!Graphics.foreground}.*)
+
+val foreground : color
+(** Default background and foreground colors (usually, either black
+ foreground on a white background or white foreground on a
+ black background).
+ {!Graphics.clear_graph} fills the screen with the [background] color.
+ The initial drawing color is [foreground]. *)
+
+
+(** {7 Some predefined colors} *)
+
+val black : color
+val white : color
+val red : color
+val green : color
+val blue : color
+val yellow : color
+val cyan : color
+val magenta : color
+
+
+(** {6 Point and line drawing} *)
+
+val plot : int -> int -> unit
+(** Plot the given point with the current drawing color. *)
+
+val plots : (int * int) array -> unit
+(** Plot the given points with the current drawing color. *)
+
+val point_color : int -> int -> color
+(** Return the color of the given point in the backing store
+ (see "Double buffering" below). *)
+
+val moveto : int -> int -> unit
+(** Position the current point. *)
+
+val rmoveto : int -> int -> unit
+(** [rmoveto dx dy] translates the current point by the given vector. *)
+
+val current_x : unit -> int
+(** Return the abscissa of the current point. *)
+
+val current_y : unit -> int
+(** Return the ordinate of the current point. *)
+
+val current_point : unit -> int * int
+(** Return the position of the current point. *)
+
+val lineto : int -> int -> unit
+(** Draw a line with endpoints the current point and the given point,
+ and move the current point to the given point. *)
+
+val rlineto : int -> int -> unit
+(** Draw a line with endpoints the current point and the
+ current point translated of the given vector,
+ and move the current point to this point. *)
+
+val curveto : int * int -> int * int -> int * int -> unit
+(** [curveto b c d] draws a cubic Bezier curve starting from
+ the current point to point [d], with control points [b] and
+ [c], and moves the current point to [d]. *)
+
+val draw_rect : int -> int -> int -> int -> unit
+(** [draw_rect x y w h] draws the rectangle with lower left corner
+ at [x,y], width [w] and height [h].
+ The current point is unchanged.
+ Raise [Invalid_argument] if [w] or [h] is negative. *)
+
+val draw_poly_line : (int * int) array -> unit
+(** [draw_poly_line points] draws the line that joins the
+ points given by the array argument.
+ The array contains the coordinates of the vertices of the
+ polygonal line, which need not be closed.
+ The current point is unchanged. *)
+
+val draw_poly : (int * int) array -> unit
+(** [draw_poly polygon] draws the given polygon.
+ The array contains the coordinates of the vertices of the
+ polygon.
+ The current point is unchanged. *)
+
+val draw_segments : (int * int * int * int) array -> unit
+(** [draw_segments segments] draws the segments given in the array
+ argument. Each segment is specified as a quadruple
+ [(x0, y0, x1, y1)] where [(x0, y0)] and [(x1, y1)] are
+ the coordinates of the end points of the segment.
+ The current point is unchanged. *)
+
+val draw_arc : int -> int -> int -> int -> int -> int -> unit
+(** [draw_arc x y rx ry a1 a2] draws an elliptical arc with center
+ [x,y], horizontal radius [rx], vertical radius [ry], from angle
+ [a1] to angle [a2] (in degrees). The current point is unchanged.
+ Raise [Invalid_argument] if [rx] or [ry] is negative. *)
+
+val draw_ellipse : int -> int -> int -> int -> unit
+(** [draw_ellipse x y rx ry] draws an ellipse with center
+ [x,y], horizontal radius [rx] and vertical radius [ry].
+ The current point is unchanged.
+ Raise [Invalid_argument] if [rx] or [ry] is negative. *)
+
+val draw_circle : int -> int -> int -> unit
+(** [draw_circle x y r] draws a circle with center [x,y] and
+ radius [r]. The current point is unchanged.
+ Raise [Invalid_argument] if [r] is negative. *)
+
+val set_line_width : int -> unit
+(** Set the width of points and lines drawn with the functions above.
+ Under X Windows, [set_line_width 0] selects a width of 1 pixel
+ and a faster, but less precise drawing algorithm than the one
+ used when [set_line_width 1] is specified.
+ Raise [Invalid_argument] if the argument is negative. *)
+
+(** {6 Text drawing} *)
+
+val draw_char : char -> unit
+(** See {!Graphics.draw_string}.*)
+
+val draw_string : string -> unit
+(** Draw a character or a character string with lower left corner
+ at current position. After drawing, the current position is set
+ to the lower right corner of the text drawn. *)
+
+val set_font : string -> unit
+(** Set the font used for drawing text.
+ The interpretation of the argument to [set_font]
+ is implementation-dependent. *)
+
+val set_text_size : int -> unit
+(** Set the character size used for drawing text.
+ The interpretation of the argument to [set_text_size]
+ is implementation-dependent. *)
+
+val text_size : string -> int * int
+(** Return the dimensions of the given text, if it were drawn with
+ the current font and size. *)
+
+
+(** {6 Filling} *)
+
+val fill_rect : int -> int -> int -> int -> unit
+(** [fill_rect x y w h] fills the rectangle with lower left corner
+ at [x,y], width [w] and height [h], with the current color.
+ Raise [Invalid_argument] if [w] or [h] is negative. *)
+
+val fill_poly : (int * int) array -> unit
+(** Fill the given polygon with the current color. The array
+ contains the coordinates of the vertices of the polygon. *)
+
+val fill_arc : int -> int -> int -> int -> int -> int -> unit
+(** Fill an elliptical pie slice with the current color. The
+ parameters are the same as for {!Graphics.draw_arc}. *)
+
+val fill_ellipse : int -> int -> int -> int -> unit
+(** Fill an ellipse with the current color. The
+ parameters are the same as for {!Graphics.draw_ellipse}. *)
+
+val fill_circle : int -> int -> int -> unit
+(** Fill a circle with the current color. The
+ parameters are the same as for {!Graphics.draw_circle}. *)
+
+
+(** {6 Images} *)
+
+type image
+(** The abstract type for images, in internal representation.
+ Vally, images are represented as matrices of colors. *)
+
+val transp : color
+(** In matrices of colors, this color represent a ``transparent''
+ point: when drawing the corresponding image, all pixels on the
+ screen corresponding to a transparent pixel in the image will
+ not be modified, while other points will be set to the color
+ of the corresponding point in the image. This allows superimposing
+ an image over an existing background. *)
+
+val make_image : color array array -> image
+(** Convert the given color matrix to an image.
+ Each sub-array represents one horizontal line. All sub-arrays
+ must have the same length; otherwise, exception [Graphic_failure]
+ is raised. *)
+
+val dump_image : image -> color array array
+(** Convert an image to a color matrix. *)
+
+val draw_image : image -> int -> int -> unit
+(** Draw the given image with lower left corner at the given point. *)
+
+val get_image : int -> int -> int -> int -> image
+(** Capture the contents of a rectangle on the screen as an image.
+ The parameters are the same as for {!Graphics.fill_rect}. *)
+
+val create_image : int -> int -> image
+(** [create_image w h] returns a new image [w] pixels wide and [h]
+ pixels tall, to be used in conjunction with [blit_image].
+ The initial image contents are random, except that no point
+ is transparent. *)
+
+val blit_image : image -> int -> int -> unit
+(** [blit_image img x y] copies screen pixels into the image [img],
+ modifying [img] in-place. The pixels copied are those inside the
+ rectangle with lower left corner at [x,y], and width and height
+ equal to those of the image. Pixels that were transparent in
+ [img] are left unchanged. *)
+
+
+(** {6 Mouse and keyboard events} *)
+
+type status =
+ { mouse_x : int; (** X coordinate of the mouse *)
+ mouse_y : int; (** Y coordinate of the mouse *)
+ button : bool; (** true if a mouse button is pressed *)
+ keypressed : bool; (** true if a key has been pressed *)
+ key : char; (** the character for the key pressed *)
+ }
+(** To report events. *)
+
+
+type event =
+ Button_down (** A mouse button is pressed *)
+ | Button_up (** A mouse button is released *)
+ | Key_pressed (** A key is pressed *)
+ | Mouse_motion (** The mouse is moved *)
+ | Poll (** Don't wait; return immediately *)
+(** To specify events to wait for. *)
+
+
+val wait_next_event : event list -> status
+(** Wait until one of the events specified in the given event list
+ occurs, and return the status of the mouse and keyboard at
+ that time. If [Poll] is given in the event list, return immediately
+ with the current status. If the mouse cursor is outside of the
+ graphics window, the [mouse_x] and [mouse_y] fields of the event are
+ outside the range [0..size_x()-1, 0..size_y()-1]. Keypresses
+ are queued, and dequeued one by one when the [Key_pressed]
+ event is specified. *)
+
+(** {6 Mouse and keyboard polling} *)
+
+val mouse_pos : unit -> int * int
+(** Return the position of the mouse cursor, relative to the
+ graphics window. If the mouse cursor is outside of the graphics
+ window, [mouse_pos()] returns a point outside of the range
+ [0..size_x()-1, 0..size_y()-1]. *)
+
+val button_down : unit -> bool
+(** Return [true] if the mouse button is pressed, [false] otherwise. *)
+
+val read_key : unit -> char
+(** Wait for a key to be pressed, and return the corresponding
+ character. Keypresses are queued. *)
+
+val key_pressed : unit -> bool
+(** Return [true] if a keypress is available; that is, if [read_key]
+ would not block. *)
+
+
+(** {6 Sound} *)
+
+val sound : int -> int -> unit
+(** [sound freq dur] plays a sound at frequency [freq] (in hertz)
+ for a duration [dur] (in milliseconds). *)
+
+(** {6 Double buffering} *)
+
+val auto_synchronize : bool -> unit
+(** By default, drawing takes place both on the window displayed
+ on screen, and in a memory area (the ``backing store'').
+ The backing store image is used to re-paint the on-screen
+ window when necessary.
+
+ To avoid flicker during animations, it is possible to turn
+ off on-screen drawing, perform a number of drawing operations
+ in the backing store only, then refresh the on-screen window
+ explicitly.
+
+ [auto_synchronize false] turns on-screen drawing off. All
+ subsequent drawing commands are performed on the backing store
+ only.
+
+ [auto_synchronize true] refreshes the on-screen window from
+ the backing store (as per [synchronize]), then turns on-screen
+ drawing back on. All subsequent drawing commands are performed
+ both on screen and in the backing store.
+
+ The default drawing mode corresponds to [auto_synchronize true]. *)
+
+val synchronize : unit -> unit
+(** Synchronize the backing store and the on-screen window, by
+ copying the contents of the backing store onto the graphics
+ window. *)
+
+
+val display_mode : bool -> unit
+(** Set display mode on or off. When turned on, drawings are done
+ in the graphics window; when turned off, drawings do not affect
+ the graphics window. This occurs independently of
+ drawing into the backing store (see the function {!Graphics.remember_mode}
+ below). Default display mode is on. *)
+
+
+val remember_mode : bool -> unit
+(** Set remember mode on or off. When turned on, drawings are done
+ in the backing store; when turned off, the backing store is
+ unaffected by drawings. This occurs independently of drawing
+ onto the graphics window (see the function {!Graphics.display_mode} above).
+ Default remember mode is on. *)
View
3  try-js_of_ocaml/Makefile
@@ -23,6 +23,7 @@ TRYOCAML_EXTRA_MODULES= \
xmlHttpRequest \
\
utils \
+ graphics \
button \
cookie \
dragnDrop
@@ -34,4 +35,4 @@ include $(ROOT)/Makefile.rules
upload:
$(SCP) -C index.html webmaster@ssh.ocamlpro.com:/home/try.ocamlpro.com/www/js_of_ocaml/index.html
$(SCP) -C try-js_of_ocaml.js webmaster@ssh.ocamlpro.com:/home/try.ocamlpro.com/www/js_of_ocaml/try-js_of_ocaml.js
- $(SCP) -C style.css webmaster@ssh.ocamlpro.com:/home/try.ocamlpro.com/www/js_of_ocaml/style.css
+ $(SCP) -C style.css webmaster@ssh.ocamlpro.com:/home/try.ocamlpro.com/www/js_of_ocaml/style.css
View
2  try-js_of_ocaml/index.html
@@ -86,7 +86,7 @@ <h1 id="main-title">Try js_of_ocaml</h1>
<div id="toplevel"></div>
</div>
<div id="buttons"></div>
-
+ <div id="graphics"></div>
<table class="zebra-striped">
<thead><tr><th id="text-commands">Commands</th><th id="text-effects">Effects</th></tr></thead>
<tr><td id="text-enter">Enter / Return</td> <td id="text-submit">Submit code</td></tr>
View
2  try-ocaml/index.html
@@ -86,7 +86,7 @@ <h1 id="main-title">Try OCaml</h1>
<div id="toplevel"></div>
</div>
<div id="buttons"></div>
-
+ <div id="graphics"></div>
<table class="zebra-striped">
<thead><tr><th id="text-commands">Commands</th><th id="text-effects">Effects</th></tr></thead>
<tr><td id="text-enter">Enter / Return</td> <td id="text-submit">Submit code</td></tr>
Please sign in to comment.
Something went wrong with that request. Please try again.