<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14"> <TITLE> The graphics library </TITLE> </HEAD> <BODY TEXT=black BGCOLOR=white> <A HREF="manual038.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual040.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> <HR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#2de52d"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc248"><B><FONT SIZE=6>Chapter 25</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=6>The graphics library</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> The <TT>graphics</TT> library provides a set of portable drawing primitives. Drawing takes place in a separate window that is created when <TT>open_graph</TT> is called.<BR> <BR> <FONT COLOR=purple>Unix:</FONT> <BLOCKQUOTE> This library is implemented under the X11 windows system. Programs that use the <TT>graphics</TT> library must be linked as follows: <PRE> ocamlc <I>other options</I> graphics.cma <I>other files</I> </PRE> For interactive use of the <TT>graphics</TT> library, do: <PRE> ocamlmktop -o mytop graphics.cma ./mytop </PRE> or (if dynamic linking of C libraries is supported on your platform), start <TT>ocaml</TT> and type <TT>#load "graphics.cma";;</TT>.<BR> <BR> Here are the graphics mode specifications supported by <TT>open_graph</TT> on the X11 implementation of this library: the argument to <TT>open_graph</TT> has the format <TT>"</TT><I>display-name</I> <I>geometry</I><TT>"</TT>, where <I>display-name</I> is the name of the X-windows display to connect to, and <I>geometry</I> is a standard X-windows geometry specification. The two components are separated by a space. Either can be omitted, or both. Examples: <DL COMPACT=compact><DT> <B><TT>open_graph "foo:0"</TT></B><DD> connects to the display <TT>foo:0</TT> and creates a window with the default geometry <DT><B><TT>open_graph "foo:0 300x100+50-0"</TT></B><DD> connects to the display <TT>foo:0</TT> and creates a window 300 pixels wide by 100 pixels tall, at location (50,0) <DT><B><TT>open_graph " 300x100+50-0"</TT></B><DD> connects to the default display and creates a window 300 pixels wide by 100 pixels tall, at location (50,0) <DT><B><TT>open_graph ""</TT></B><DD> connects to the default display and creates a window with the default geometry. </DL> </BLOCKQUOTE> <FONT COLOR=purple>Windows:</FONT> <BLOCKQUOTE> This library is available both for standalone compiled programs and under the toplevel application <TT>ocamlwin.exe</TT>. For the latter, this library must be loaded in-core by typing <PRE> #load "graphics.cma";; </PRE></BLOCKQUOTE> The screen coordinates are interpreted as shown in the figure below. Notice that the coordinate system used is the same as in mathematics: <I>y</I> increases from the bottom of the screen to the top of the screen, and angles are measured counterclockwise (in degrees). Drawing is clipped to the screen. <BR> <BR> <DIV ALIGN=center> <IMG SRC="libgraph.gif"> </DIV> <BR> <a HREF=libref/Graphics.html> Module <tt>Graphics</tt>: machine-independent graphics primitives</a> <BR> <BR> <BR> <BR> <HR> <A HREF="manual038.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual040.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> </BODY> </HTML>