Introduction
This chapter presents the Graphics library, which is included
in the distribution of the Objective CAML-language. This library is designed in
such a way that it works identically under the main graphical interfaces
of the most commonly used operating systems: Windows, MacOS,
Unix with X-Windows. Graphics permits the realization of
drawings which may contain text and images, and it handles basic events
like mouse clicks or pressed keys.
The model of programming graphics applied is the ``painter's model:''
the last touch of color erases the preceding one. This is an imperative
model where the graphics window is a table of points which is physically
modified by each graphics primitive. The interactions with the mouse and
the keyboard are a model of event-driven programming: the primary function
of the program is an infinite loop waiting for user interaction. An
event starts execution of a special handler, which then returns to the
main loop to wait for the next event.
Although the Graphics library is very simple, it is sufficient
for introducing basic concepts of graphical interfaces, and it also
contains basic elements for developing graphical interfaces that are
rich and easy to use by the programmer.