Javascript binding for Graphics lib
include module type of Graphics
exception Graphic_failure of string
val close_graph : unit -> unit
val set_window_title : string -> unit
val resize_window : int -> int -> unit
val clear_graph : unit -> unit
val rgb : int -> int -> int -> color
val set_color : color -> unit
val plot : int -> int -> unit
val plots : (int * int) array -> unit
val point_color : int -> int -> color
val moveto : int -> int -> unit
val rmoveto : int -> int -> unit
val current_x : unit -> int
val current_y : unit -> int
val current_point : unit -> int * int
val lineto : int -> int -> unit
val rlineto : int -> int -> unit
val curveto : (int * int) -> (int * int) -> (int * int) -> unit
val draw_rect : int -> int -> int -> int -> unit
val draw_poly_line : (int * int) array -> unit
val draw_poly : (int * int) array -> unit
val draw_segments : (int * int * int * int) array -> unit
val draw_arc : int -> int -> int -> int -> int -> int -> unit
val draw_ellipse : int -> int -> int -> int -> unit
val draw_circle : int -> int -> int -> unit
val set_line_width : int -> unit
val draw_char : char -> unit
val draw_string : string -> unit
val set_font : string -> unit
val set_text_size : int -> unit
val text_size : string -> int * int
val fill_rect : int -> int -> int -> int -> unit
val fill_poly : (int * int) array -> unit
val fill_arc : int -> int -> int -> int -> int -> int -> unit
val fill_ellipse : int -> int -> int -> int -> unit
val fill_circle : int -> int -> int -> unit
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
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 |
val loop_at_exit : event list -> (status -> unit) -> unit
val key_pressed : unit -> bool
val sound : int -> int -> unit
val auto_synchronize : bool -> unit
val synchronize : unit -> unit
val display_mode : bool -> unit
val remember_mode : bool -> unit
Initializations
type of a graphic context
val open_graph : string -> 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.
use a canvas to setup the current context
Mouse and keyboard events
Loops forever and listen to the given events. Those events automatically returns a status record, which is used by the function given in argument.
Mouse and keyboard polling
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
.
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.