module Graphics:Machine-independent graphics primitives.sig..end
exception Graphic_failure of string
val open_graph : string -> unitval close_graph : unit -> unitval set_window_title : string -> unitval resize_window : int -> int -> unitval clear_graph : unit -> unitval size_x : unit -> intGraphics.size_y.val size_y : unit -> int0 .. 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.typecolor =int
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 -> colorrgb 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 -> unitval background : colorGraphics.foreground.val foreground : colorGraphics.clear_graph fills the screen with the background color.
The initial drawing color is foreground.val black : colorval white : colorval red : colorval green : colorval blue : colorval yellow : colorval cyan : colorval magenta : colorval plot : int -> int -> unitval plots : (int * int) array -> unitval point_color : int -> int -> colorval moveto : int -> int -> unitval rmoveto : int -> int -> unitrmoveto dx dy translates the current point by the given vector.val current_x : unit -> intval current_y : unit -> intval current_point : unit -> int * intval lineto : int -> int -> unitval rlineto : int -> int -> unitval curveto : int * int -> int * int -> int * int -> unitcurveto 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 -> unitdraw_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 -> unitdraw_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 -> unitdraw_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 -> unitdraw_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 -> unitdraw_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 -> unitdraw_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 -> unitdraw_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 -> unitset_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.val draw_char : char -> unitGraphics.draw_string.val draw_string : string -> unitval set_font : string -> unitset_font
is implementation-dependent.val set_text_size : int -> unitset_text_size
is implementation-dependent.val text_size : string -> int * intval fill_rect : int -> int -> int -> int -> unitfill_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 -> unitval fill_arc : int -> int -> int -> int -> int -> int -> unitGraphics.draw_arc.val fill_ellipse : int -> int -> int -> int -> unitGraphics.draw_ellipse.val fill_circle : int -> int -> int -> unitGraphics.draw_circle.type image
val transp : colorval make_image : color array array -> imageGraphic_failure
is raised.val dump_image : image -> color array arrayval draw_image : image -> int -> int -> unitval get_image : int -> int -> int -> int -> imageGraphics.fill_rect.val create_image : int -> int -> imagecreate_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 -> unitblit_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.type status = {
|
mouse_x : |
(* | X coordinate of the mouse | *) |
|
mouse_y : |
(* | Y coordinate of the mouse | *) |
|
: |
(* | true if a mouse button is pressed | *) |
|
keypressed : |
(* | true if a key has been pressed | *) |
|
key : |
(* | the character for the key pressed | *) |
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 | *) |
val wait_next_event : event list -> statusPoll 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.val mouse_pos : unit -> int * intmouse_pos() returns a point outside of the range
0..size_x()-1, 0..size_y()-1. : unit -> booltrue if the mouse button is pressed, false otherwise.val read_key : unit -> charval key_pressed : unit -> booltrue if a keypress is available; that is, if read_key
would not block.val sound : int -> int -> unitsound freq dur plays a sound at frequency freq (in hertz)
for a duration dur (in milliseconds).val auto_synchronize : bool -> unitTo 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 -> unitval display_mode : bool -> unitGraphics.remember_mode
below). Default display mode is on.val remember_mode : bool -> unitGraphics.display_mode above).
Default remember mode is on.