Library
Module
Module type
Parameter
Class
Class type
Javascript binding for Graphics lib
include module type of Graphics
val rgb : int -> int -> int -> color
val set_color : color -> unit
val background : color
val foreground : color
val black : color
val white : color
val red : color
val green : color
val blue : color
val yellow : color
val cyan : color
val magenta : color
val point_color : int -> int -> color
val transp : color
val draw_image : image -> int -> int -> unit
val get_image : int -> int -> int -> int -> image
val create_image : int -> int -> image
val blit_image : image -> int -> int -> unit
Open a graphics window. 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. Specification can be found at http://www.w3schools.com/jsref/met_win_open.asp. Note: an extra specification is available, "target", to specifies the target attribute or the name of the window.
val open_canvas : Js_of_ocaml.Dom_html.canvasElement Js_of_ocaml.Js.t -> unit
use a canvas to setup the current context
val get_context : unit -> context
Get the current context
val set_context : context -> unit
Set the current context
Loops forever and listen to the given events. Those events automatically returns a status record, which is used by the function given in argument.
val mouse_pos : unit -> (int * int) Lwt.t
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 Lwt.t
Return true
if the mouse button is pressed, false
otherwise.
val read_key : unit -> char Lwt.t
Wait for a key to be pressed, and return the corresponding character. Keypresses are queued.