module Gctx:sig
..end
The drawing primitives in this module are all relative to the graphics context. This means that when a widget needs to draw on the screen, it need not know its absolute position. The graphics context is responsible for translating the relative positions passed into the drawing routines into absolute positions on the screen.
The graphics context also includes other information for basic drawing (such as the current pen color.)
Note that this module defines a persistent (immutable) data structure. The
operations here use a given graphics context to create a new one with the
specified characteristics. They do not modify their arguments.
type
gctx
type
color = {
|
r : |
|
g : |
|
b : |
0 .. 255
inclusiveval black : color
val white : color
val red : color
val green : color
val blue : color
val yellow : color
val cyan : color
val magenta : color
val open_graphics : unit -> unit
val top_level : gctx
val translate : gctx -> int * int -> gctx
val with_color : gctx -> color -> gctx
typeposition =
int * int
typedimension =
int * int
val draw_line : gctx -> position -> position -> unit
val draw_string : gctx -> position -> string -> unit
val draw_rect : gctx -> position -> dimension -> unit
val fill_rect : gctx -> position -> dimension -> unit
val draw_ellipse : gctx -> position -> int -> int -> unit
val text_size : string -> dimension
type
event
type
event_type =
| |
KeyPress of |
| |
MouseDown |
| |
MouseUp |
| |
MouseMove |
| |
MouseDrag |
val event_type : event -> event_type
val event_pos : event -> gctx -> position
val wait_for_event : unit -> event
val make_test_event : event_type -> position -> event