		    BGI Library -- Basic Concepts
		    -----------------------------
		       Excerpts from the manual

		  Copyright (C) 1995 G & Y Systems.

Coordinate System.

BGI library uses a coordinate system in which the origin (i.e, the
point (0,0)) is at the upper left corner of the screen (unless moved
by a viewport, as discussed below).  The positive x-axis extends
horizontally towards the right, and the positive y-axis extends
vertically downward.  Notice that this is vertically inverted from
the normal Cartesian coordinate system, in which the positive y-axis
extends vertically upward.

Current Pointer.

BGI library employs the concept of a current pointer, or CP.  The
current pointer is similar to the cursor on a text screen, in that it
defines a currently active position.  However, in contrast to a text
screen, the current pointer is never visible.

A number of routines either affect the position of the CP, or are
affected by the location of the CP.  In particular, the following
procedures move the CP to the upper left corner of the current
viewport (i.e., to position (0,0)):

	initgraph()
	cleardevice()
	setviewport()
        clearviewport()

The following functions return the current x and y coordinates of the
CP, respectively: 	
	getx()
        gety()

The following two functions move the CP from its current locations to
another location, the first moving it to an absolute location, and
the second to a position displaced from the current position by a
specified amount:

	moveto()
        moverel()

The following two functions move the CP in the same way as the
preceding commands, and also draw a line between the old and the new
locations of the CP:

	lineto()
        linerel()

Finally, the text-writing procedure outtext() moves the CP to the
right of the last character drawn -- but only if text is currently
left-justified , and the current text direction is horizontal.

Viewports.

BGI library supports the concept of viewports.  Viewports are
rectangular windows on the screen which define a new location for the
coordinate system, and optionally (if viewport clipping is on)
restrict the active region of the screen to the viewport itself.
When graphics is initialized the viewport is set to the entire screen
by default.  If a different viewport is selected, position arguments
for almost all functions are relative to the upper left corner of the
viewport.  Thus defining a viewport effectively moves the location of
the coordinate system.

If viewport clipping is enabled when the viewport is defined, the
viewport is the only region of the image that is affected by graphics
commands.  For example, if a line is drawn from within the viewport
to a point outside the viewport, only the part of the line within the
viewport is actually drawn.  If viewport clipping is not enabled, all
positions in the image may be affected by graphics commands.  In this
case, the only effect of defining the viewport is to move the
location of the coordinate system origin.

Note that the location of the current pointer is never clipped at a
viewport boundary, even if clipping is enabled.  This it is possible
to move the CP out of the current viewport.

Linux Integration

BGI library provides transparent console switching under Linux.
Whenever a console switch is performed via alt-Fx key, the library
automatically switches the display back into the text mode. The
display is restored back into the graphics mode whenever a console
from which the graphical program has been started is made active
again. 

The library also installs several signal handlers that attempt to
intercept most fatal errors and restore the console back into the text
mode.

For further information and examples, please examine the file demo.c,
which demonstrates the usage of most of the functions documented
below. 

			   Function listing
			   ----------------
 
arc() 

Description   Draws a circular arc centered at point (XCenter, YCenter) with
              radius Radius, starting at angle StAngle and ending at angle
              EndAngle.

Declaration   void arc (int xcenter, int ycenter,
                            int stangle, int endangle, int radius);

Remarks       The arc is drawn using a solid line having the current line
              thickness. (The current line thickness is that set by the last
              call to setlinestyle(). If setlinestyle() has not been called, 
              the line thickness is one.) The angles are given in degrees.

              The endpoints and the center of the last arc drawn may be
              obtained by calling the function getarccoords(). This 
              information is useful if other objects, such as lines, need
              to be connected to the endpoints of the arc.

See also      getarccoords(), ellipse(), circle(), pieslice(), 
              getaspectratio(), setlinestyle()
 
bar() 

Description   Draws a filled bar with the upper left corner at point
              (x1,x1) and the lower right corner at (x2,x2).

Declaration   void bar (int x1, int y1, int x2, int y2);

Remarks       The bar is filled with the fill style defined by the 
              function setfillstyle() and/or setfillpattern().

              Lines are not drawn around the bar. To obtain a bar with
              lines drawn arownd it, use function bar3d() with the depth
              parameter set to zero.

See Also      bar3d(), setfillstyle(), setfillpattern()
 
bar3d()

Description   Draws a filled bar with the upper left corner at the point
              (x1,y1) and the lower right corner at (x2,y2), with additional
              "depth" lines to produce a three-dimensional appearance.

Declaration   void bar3d (int x1, int y1, int x2, int y2,
                              int depth, int top);

Remarks       The bar is filled with the style specified by the function 
              setfillstyle() and/or setfillpattern(). The bar is then outlined
              using the line style and thickness specified by the function
              setlinestyle.

              If the depth parameter is not zero, additional
              lines are drawn to give a three-dimensional appearance. If
              the Depth parameter is zero, a two-dimensional outlined and
              filled bar is drawn. (Function Bar draws two-dimensional
              bars without the outlining lines.)

              If top is true (1), a top is drawn on the bar. The top should 
              be set to false (0) when stacking several bars on top of each 
              other to form a stacked bar chart. 

See Also      bar(), setfillstyle(), setfillpattern(), setlinestyle()
  
circle()

Description   Draws a circle centered at the point (xcenter,ycenter)
              with radius Radius.

Declaration   void circle (int xcenter, int ycenter,
                               int radius);

Remarks       The circle is drawn using the line thickness specified
              by the function setlinestyle(). If setlinestyle() has not been
              called, the default line thickness is one.

              A circle filled with a particular color and style can be
              drawn using the function fillellipse().

              The center and the endpoints of the last circular or 
              elliptical arc drawn may be obtained using the function
              getarccoords(). This is useful if other objects, such as 
              lines, are to be attached to the arc endpoints. For a full
              circle, the beginning and ending points are the same and
              have the coordinates (xcenter + radius,ycenter).

See also      arc(), getarccoords(), pieslice(), ellipse(), getaspectratio(),
              setlinestyle()
 
cleardevice()

Description   Fills the entire image with the specified background color
              and moves the current pointer (CP) to the upper left corner
              of the current viewport.

Declaration   void cleardevice();

Remarks       None

see also      clearviewport(), closegraph()
 
clearviewport() 

Description   Clears the currently active viewport, filling it with
              the currently set background color, and moves the current
              pointer (CP) to the upper left corner of the viewport.

Declaration   void clearviewport();

Remarks       In order to clear the entire screen, it is better to use the
              function cleardevice(). 

See also      setviewport(), getviewsettings(), cleardevice(), setbkcolor()
 
closegraph()

Description   Closes down the graphics system.

Declaration   void closegraph()


Remarks       closegraph() deallocates all memory used by the graphics
              system, and then restores the screen to the text mode.
              It should always be called prior to program termination
              to avoid leaving the screen in graphics mode.

See also      initgraph(), cleardevice()
 
drawpoly()

Description   Draws a polygon.

Declaration   void drawpoly (int numpoints,
                             int *polypoints)

Remarks       The variable numpoints is the number of vertices
              in the polygon. The variable polypoints is the list of
              vertices; each vertex consisting of x and y values
              indicating its location on the cartesian coordinate
              plane. X and y are integers. The following type can been
              declared for use in constructing the vertex list:

                 struct point {
                                int x;
                                int y;
                              }
              
              The vertex list, polypoints, can then be an array of type point.
              However, it does not need to be, because polypoints is a 
              pointer and, therefore, can be any data structure. At times it
              is more convenient to use another data type, such as simple 
              array, for polypoints.

              By default, the lines of the polygon overwrite the underlying
              image. However, if setwritemode() has been called with an 
              argument XOR_PUT, the lines are XORed onto the image. 
              (See the description of setwritemode() for a discussion of 
              XOR mode and its uses.)

              If a closed polygon needs to be formed, the first and last
              vertices should be identical. (The related function fillpoly()
              always makes a closed polygon, even if the first and last
              vertices given are not coincident.)

See also      fillpoly(), setwritemode()
 
ellipse() 

Description   Draws an ellipse or partial ellipse centered at point
              (xcenter,ycenter), having the horizontal radius xradius
              and vertical radius yradius, starting at angle stangle
              and ending at angle endangle.

Declaration   void ellipse (int xcenter, int ycenter,
                                int stangle, int endangle,
                                int xradius, itn yradius);

Remarks       The ellipse or partial ellipse is drawn using the line
              thickness as specified by the function setlinestyle(). If
              setlinestyle() has not been called, line thickness is one.

              stangle and endangle are specified in degrees. For a complete
              ellipse, set stangle to 0 degrees and endangle at 360 degrees.

              The center and endpoints of the last arc drawn (elliptical or
              circular) may be obtained by calling the function getarccoords().
              This information is useful if other object, such as lines, need
              to be connected to the endpoints of the arc. For a full ellipse,
              the starting and ending points are coincidental, and are located
              at (xcenter + xradius, ycenter).

See also      circle(), arc(), getarccoords(), pieslice(), setlinestyle() 
 
fillellipse() 

Description   Draws and fills an ellipse, centered at point (xcenter,ycenter),
              having the horizontal radius of xradius and a vertical radius
              of yradius.

Declaration   void fillellipse (int xcenter, 
                                int ycenter,
                                int xradius, 
                                int yradius)

Remarks       The ellipse is drawn using the line thickness  specified
              by the function setlinestyle(). If setlinestyle() has not been
              called, the thickness is one.

              The ellipse is filled using the pattern specified by the 
              function setfillstyle() and/or setfillpattern(). If neither
              function has been called, the solid fill pattern is used
              by default.

See also      fillpoly(), bar(), bar3d(), setfillstyle(), setfillpattern(),
              setlinestyle(), getaspectratio()
 
fillpoly()

Description   Draws a polygon and fills it with the current fill pattern.

Declaration   void fillpoly (int numpoints,
                             int *polypoints)

Remarks       Numpoints is the number of points in a polygon. Polypoints
              is the list of vertex coordinates. The coordinates are (x,y) 
              pairs to locate the vertex points on a cartesian plane. X and y
              values are integers. The following type can be declared for
              constructing a list of vertices:

                 struct point {
                                int x;
                                int y;
                              }
 
              The vertex list, polypoints, can then be an array of type point.
              However, it does not need to be, because polypoints is a 
              pointer and, therefore, can be any data structure. At times it
              is more convenient to use another data type, such as simple 
              array, for polypoints.

              The polygon is always closed, that is the first and last
              vertices are connected by a line segment. Therefore, it
              is not necessary to list the first vertex again at the
              end of the list, though doing so will not cause problems.
              (This is in contrast to function drawpoly(), which draws an
              open polygon unless the first and last vertices are the
              same.)
             
              The polygon is filled with style as specified by the function
              setfillstyle() and/or setfillpattern().

See Also      drawpoly(), setfillstyle(), setfillpattern()
 
floodfill()

Description   Flood-fills the enclosed area on the screen.

Declaration   void floodfill(int x,
                             int y,
                             int border)

Remarks       floodfill() fills an enclosed area with the current fill
              pattern and fill color.  X and y specify the reference,
              or seed, point.  Border specifies the color that bounds 
              the area.  If the reference point is inside the bound 
              area, the inside of the area will be filled.  If the
              reference point is outside of the bound area, the outside
              will be filled.

See also      fillpoly(), setcolor(), setfillstyle()
 
getarccoords() 

Description   Obtains the coordinates of the endpoints and center of the
              last arc (elliptical or circular) drawn.

Declaration   void getarccoords (struct arccoordstype *arccoords);

Remarks       This function returns the coordinates from the last call
              to functions arc(), ellipse(), pieslice(), or sector(). The 
              coordinates are returned in variable of type arccoordstype, 
              which has the following declaration:

                 struct arccoordstype
                    {
                       int x, y;
                       int xstart, ystart, xend, yend;
                    }

              In this declaration (x,y) is the center of the arc,
              (xstart,ystart) are the starting point, and (xend,yend) is
              the ending point. For a full ellipse the starting and ending
              points are the same, and are located at (xcenter + xradius,
              ycenter). For a full circle, the starting and ending points
              are also the same, and are located at (xcenter + radius,
              ycenter).

              The information returned by this function is useful, for
              example, for joining a line to the endpoint(s) of an arc.
 
getaspectratio()

Description   Obtains information for calculating the aspect ratio of the
              virtual image.

Declaration   void getaspectratio (int *xasp, *yasp)

Remarks       The aspect ratio can be calculated by dividing xasp by yasp.
              It is useful in ensuring that the horizontal and vertical
              dimensions of an object (such as a rectangle or an ellipse)
              are, in fact, proportional.
 
getbkcolor()

Description   Returns the current background color

Declaration   int getbkcolor() 

Remarks       The following colors are defined in graphics.h:
       
                 enum COLORS
                    {
                       BLACK,
                       BLUE,
                       GREEN,
                       CYAN,
                       RED,
                       MAGENTA,
                       BROWN,
                       LIGHTGRAY,
                       DARKGRAY,
                       LIGHTBLUE,
                       LIGHTGREEN,
                       LIGHTCYAN,
                       LIGHTRED,
                       LIGHTMAGENTA,
                       YELLOW,
                       WHITE
                    };

              The background color can be changed with the function
              setbkcolor(). 

See also      setbkcolor(), getcolor(), setcolor(), getmaxcolor()
    
getcolor()

Description   Returns the current drawing color.

Declaration   int getcolor()

Remarks       The following colors are defined in graphics.h:
       
                 enum COLORS
                    {
                       BLACK,
                       BLUE,
                       GREEN,
                       CYAN,
                       RED,
                       MAGENTA,
                       BROWN,
                       LIGHTGRAY,
                       DARKGRAY,
                       LIGHTBLUE,
                       LIGHTGREEN,
                       LIGHTCYAN,
                       LIGHTRED,
                       LIGHTMAGENTA,
                       YELLOW,
                       WHITE
                    };

              The foreground color can be changed with the function
              setcolor().

See also      setcolor(), getbkcolor(), setbkcolor(), getmaxcolor()
 
getdefaultpalette()

Description   Returns a structure that describes default color palette.

Definition    palettetype *getdefaultpalette()

Remarks       The following structure is defined in graphics.h to
              describe the palette:

                 struct palettetype
                    {
                       unsigned size;
                       int colors[MAXCOLORS+1];
                    }
              
              size specifies the number of colors used in the current
              palette.  colors is an array containing the color numbers 
              each entry in the palette.  Only the first size entries
              in the array are valid. 
 
              MAXCOLORS is defined in graphics.h as having a value of 255.

              Number of colors in the palette depends on the graphical 
              adapter and graphical mode being used.

See also      setallpalette()
 
getfillpattern() 

Description   Obtains the current user-defined fill pattern.

Declaration   void getfillpattern (char *pattern);

Remarks       The type of the Pattern parameter differs from that in
              Borland Graphics Interface (BGI) in that it is a variable
              of FillPatternType, defined as:

              Obtaining the current fill pattern is useful when the
              user-defined fill pattern needs to be temporarily changed, and
              later restored to the original.

See also      setfillpattern(), setfillstyle(), getfillstyle()
 
getfillsettings()

Description   Obtains the currently active fill style.

Declaration   void getfillsettings (struct fillsettingstype *fillinfo)

Remarks       The following structure which is used to return fill style
              information is defined in graphics.h:
                 struct fillsettingstype
                    {
                       int pattern;
                       int color;
                    }

              Obtaining current fill style is useful when the pattern
              needs to be temporarily changed, and later the original
              pattern restored.

See also      setfillstyle(), setfillpattern(), getfillpattern()
 
getgraphmode()

Description   Returns the current graphics mode.

Declaration   int getgraphmode()

Remarks       The following graphics modes are defined in graphics.h:

                 #define G640x200x16        0x0E
		 #define G640x350x16        0x10
		 #define G640x480x16        0x12
		 #define G320x200x256       0x13
		 
		 #define G800x600x16        0x102
		 #define G1024x768x16       0x104

		 #define G640x400x256       0x100
		 #define G640x480x256       0x101
		 #define G800x600x256       0x103
		 #define G1024x768x256      0x105

		 #define GRAPHMONO          0x0f


		 #define TERMINAL_MODE      0xB

              getgraphmode() should not be called before initgraph().

See also      initgraph(), setgraphmode(), restorecrtmode()
 
getimage() 

Description   Transfers a rectangular block of pixels from the screen to 
              the memory.

Declaration   void getimage (int x1, int y1, int x2, int y2, void *bitmap)

Remarks       (x1,y1) is the upper LEFT corner of the block region, and
              (x2,y2) is the lower RIGHT corner. bitmap is a pointer to
              a pre-allocated memory where the image will be stored.

              imagesize() should always be used to calculate the
              amount of memory needed to store the image.

See also      putimage(), imagesize()
 
getmaxcolor()

Description   This function returns the highest possible color that can
              be passed to setcolor() function.

Declaration   int getmaxcolor()

Remarks       Value returned by this function depends on the graphics
              mode being used.

See also      getcolor(), setcolor(), getbkcolor(), setbkcolor()
 
getmaxmode()

Description   Returns the maximum graphics mode for the graphics adapter
              being used.

Declaration   int getmaxmode()

Remarks       The following graphics modes are defined in graphics.h:

                 #define G640x200x16        0x0E
		 #define G640x350x16        0x10
		 #define G640x480x16        0x12
		 #define G320x200x256       0x13

		 #define G800x600x16        0x102
		 #define G1024x768x16       0x104

		 #define G640x400x256       0x100
		 #define G640x480x256       0x101
		 #define G800x600x256       0x103
		 #define G1024x768x256      0x105

		 #define GRAPHMONO          0x0f
 
getmaxx()

Description   This function returns the maximum horizontal pixel on the
              screen.

Declaration   int getmaxx()

Remarks       The value returned by getmaxx() is independent of the current
              viewport settings. The point (getmaxx(), getmaxy()) is the 
              lower RIGHT corner of the screen.

              The functions getmaxx() and getmaxy() are used for positioning
              texts and centering objects.

See also      getx(), gety(), getmaxy()
 
getmaxy()

Description   This function returns the maximum vertical pixel on the
              screen.

Declaration   int getmaxy()

Remarks       The value returned by getmaxy() is independent of the current
              viewport settings. The point (getmaxx(), getmaxy()) is the 
              lower RIGHT corner of the image.

              The functions getmaxx() and getmaxy() are used for positioning
              texts and centering objects.

See also      getx(), gety(), getmaxx()
 
getpalette()

Description   Returns the description of the current color palette.

Declaration   void getpalette(struct palettetype *palette)

Remarks       The following structure is defined in graphics.h to
              describe the color palette:

                 struct palettetype
		    {
		       unsigned size;
		       int colors[MAXCOLORS+1];
		    }

              size defines the number of colors in the current palette.
              colors is an array containing the color numbers for each
              entry in the palette.  Only the first size entries in the
              array are valid.

              MAXCOLORS is defined in graphics.h as having a value of 255.

              Number of colors in the palette depends on the graphical 
              adapter and graphical mode being used.

See also      setpalette(), setallpalette()
 
getpalettesize()

Description   Returns the number of colors available in current color
              palette.

Declaration   int getpalettesize()

Remarks       None.

See also      setpalette(), setallpalette()
 
getpixel()

Description   This function returns the color of the pixel at the position
              (X,Y) on the screen.

Declaration   unsigned getpixel(int x, int y)

Remarks       The following colors, as defined in graphics.h, can be
              returned by this function:

	      enum COLORS
                 {
                    BLACK,
                    BLUE,
                    GREEN,
                    CYAN,
                    RED,
                    MAGENTA,
                    BROWN,
                    LIGHTGRAY,
                    DARKGRAY,
                    LIGHTBLUE,
                    LIGHTGREEN,
                    LIGHTCYAN,
                    LIGHTRED,
                    LIGHTMAGENTA,
                    YELLOW,
                    WHITE
                  }

See also      putpixel(), getimage(), putimage()
 
gettextsettings()

Description   This function returns the presently active font, text
              direction and text size, as well as the horizontal and
              vertical justification.

Declaration   void gettextsettings(struct textsettingstype *texttypeinfo);

Remarks       The text settings are returned in a structure of type
              textsettingstype, which is defined as:

              struct textsettingstype
                 {
                    int font;
                    int direction;
                    int charsize;
                    int horiz;
                    int vert;
                 }

              Obtaining text settings is useful when a temporary
              change is desired, with later restoration of the original
              settings.

See also      settextstyle(), settextjustify()
 
getviewsettings()

Description   This function returns the location and clipping state of the
              presently active viewport.

Declaration   void getviewsettings(struct viewporttype *viewportinfo)

Remarks       The view settings are returned in a structure of type 
              viewporttype, which is defined as:

              struct viewporttype
                 {
                    int left, top, right, bottom;
                    int clip;
                 }

              clip is a boolean that can have a value of either true (1)
              or false (0).

              Obtaining the view settings is useful for temporarily 
              switching to a different view port, and later restoring
              the current view port.

See also      setviewport(), clearviewport()
 
getx()

Description   This function returns the horizontal component of the current
              pointer (CP).

Declaration   int getx()

Remarks       The value returned by getx is viewport relative.

See also      gety(), getmaxx(), getmaxy(), setviewport()
 
gety()

Description   This function returns the vertical component of the current
              pointer (CP).

Declaration   int gety()

Remarks       The value returned by gety() is viewport relative.

See also      getx(), getmaxx(), getmaxy(), setviewport()
 
getlinesettings()

Description   Obtains the presently active line style.

Declaration   getlinesettings(struct linesettingstype *lineinfo);

Remarks       The following structure is defined in the graphics.h:

              struct linesettingstype
                 {
                    int      linestyle;
                    unsigned upattern;
                    int      thickness;
                 }

              The following enumerated types are defined in graphics.h
              to define line style:

                 enum line_styles /* Line styles for get/setlinestyle */
                    {
                       SOLID_LINE   = 0,
                       DOTTED_LINE  = 1,
                       CENTER_LINE  = 2,
                       DASHED_LINE  = 3,
                       USERBIT_LINE = 4 /* User defined line style */
                    }

              The line can be of arbitrary thickness.  However, for compati-
              bility, two enumerated types are defined for specifying line 
              thickness:

              enum line_widths /* Line widths for get/setlinestyle */
                 {
                    NORM_WIDTH  = 1,
                    THICK_WIDTH = 3
                 }

              Obtaining the current line style can be useful in temporarily
              changing the line style.

See also      setlinestylescale(), getlinestylescale()
 
grapherrormsg()

Description   This function returns a string describing the error condition
              associated with the specified error code.

Declaration   char *grapherrormsg(int errorcode)

Remarks       errorcode should be a value returned by function graphresult()
              and stored in a temporary variable. The returned string is a 
	      description of the error in plain language. 

              If the value of the errorcode is not valid, grapherrormsg()
              returns the string "Undefined error code."

See also      graphresult()  
 
graphresult()

Description   This function returns the current error status.

Declaration   int graphresult()

Remarks       Many error messages are detected if they occur, and posted
              as corresponding error codes to an internal variable which
              may be accessed through graphresult(). Note that the internal
              error variable is always reset to zero after graphresult() is
              called. Therefore, the value of graphresult() should always
              be assigned to a variable if you are going to refer to it
              again.

              The following enumerated types are defined to identify the 
              errors:

              enum graphics_errors /* graphresult error return codes */
                 {
                    grOk                          =   0,
                    grNoInitGraph                 =  -1,
                    grNotDetected                 =  -2,
                    grFileNotFound                =  -3,
                    grInvalidDriver               =  -4,
                    grNoLoadMem                   =  -5,
                    grNoScanMem                   =  -6,
                    grNoFloodMem                  =  -7,
                    grFontNotFound                =  -8,
                    grNoFontMem                   =  -9,
                    grInvalidMode                 = -10,
                    grError                       = -11,
                    grIOerror                     = -12,
                    grInvalidFont                 = -13,
                    grInvalidFontNum              = -14,
                    grInvalidDeviceNum            = -15,
                    grInvalidVersion              = -18,
                    grReversArc                   = -19,
                    grNullRadCircle               = -20,
                    grReversAngleEllipse          = -21,
                    grNullRadEllipse              = -22,
                    grErrMemory                   = -23,
                    grNoCorrectParFillarea        = -24,
                    grNullRadFillellipse          = -25,
                    grReversAnglePieslice         = -26,
                    grReversAngleSector           = -27,
                    grLargeImagesize              = -28,
                    grVGAOnly                     = -29,
                    grNotOpenTtyInitialize        = -30,
                    grErrMemMapInitialize         = -31,
                    grIOErrorGetpixel             = -32,
                    grNoCorrectParSetviewport     = -33,
                    grNoCorrectParBar             = -34,
                    grNoCorrectParBar3d           = -35,
                    grNotEnoughParFillpoly        = -36,
                    grNotEnoughParDrawpoly        = -37,
                    grDataErrorSetlinestyle       = -38,
                    grLargeNumFontInstalluserfont = -39,
                    grIncorrSetaspect             = -40,
                    grIncorrRadPieslice           = -41,
                    grIncorrRadSector             = -42,
                    grIncorrSetpalette            = -43,
                    grIncorrSetRGB                = -44,
                    grSetfillpatt                 = -45,
                    grSetfillsty                  = -46,
                    grSetWriteMode                = -47,
                    grTextJust                    = -48,
                    grTextStyle                   = -49,
                    grSetUserDefChar              = -50
                  };

              None of these errors are fatal -- that is, none of them
              results in program termination. If the error condition
              occurs, the worst that usually happens is that part of the
              program does not function as expected: either it does the
              wrong thing, or it does not do anything at all.

              If an error is detected, i.e., the function returns not 0
              (GrOK), then you may want to pass the error code to function
              grapherrormsg(), which returns a string describing the problem
              in plain language.

See also      grapherrormsg()
      
imagesize()

Description   This function determined the amount of memory that must be
              allocated to accomodate a rectangular region of the image
              to be copied to the memory using the function getimage().

Declaration   int imagesize(int x1, int y1, int x2, int y2)

Remarks       This function should always be used to calculate the amount 
              of memory needed for a call to getimage().

See also      getimage(), putimage()
 
initgraph()

Description   This function initializes the graphics system.

Declaration   void initgraph ( int *graphdriver, 
                               int *graphmode, 
                               char *pathtofonts )

Remarks       graphdriver argument specifies the graphics system
              should automatically determine which graphics adapter
              is being used.  The value of the variable passed as
              this argument will typically have one of the two values defined
              in graphics.h, DETECT or NODETECT.  DETECT should always
              be used, NODETECT is reserved for special versions of the
              library.

              graphmode specifies the graphical resolution that will be
              used by the graphics system.  The following symbolic 
              contstants have been defined in graphics.h for use with
              this argument:

                 #define G640x200x16        0x0E
                 #define G640x350x16        0x10
                 #define G640x480x16        0x12
                 #define G320x200x256       0x13

                 #define G800x600x16        0x102
                 #define G1024x768x16       0x104

                 #define G640x400x256       0x100
                 #define G640x480x256       0x101
                 #define G800x600x256       0x103
                 #define G1024x768x256      0x105

                 #define GRAPHMONO          0x0f

	
              The final argument, pathtofonts, specifies either absolute
              or relative path to the directory where stroked font files
              (*.chr files) are located.  If the font files reside in the 
              current directory, then a null string ("") may be used for 
              pathtodriver.  The na

              A call to function graphresult() should always be made 
              immediately after the call to initgraph(), to make sure that the 
              graphics system was successfully initialized. If the initia-
              lization was successful, graphresult() would return 0 (GrOK).

See also      closegraph(), graphresult(), grapherrormsg()
 
line()

Description   This function draws a line from a point (x1,y1) to the point
              (x2,y2).

Declaration   void line(int x1, int y1, int x2, int y2);

Remarks       The line is drawn using the current line style and thickness.
              The line style and thickness are set with the function
              setlinestyle(). If setlinestyle() has not been called, then by
              default, the line is solid with a with of 1 pixel.

              By default, the line overwrites the underlying image.
              However, if setwritemode() has been called with an argument
              XOR_Put, the line is XORed onto the image -- that is
              the pixels which are turned off in the underlying image
              are turned on, and those which are on are turned off.
              See the description of setwritemode() for the description
              of XOR mode and its uses.

See also      lineto(), linerel(), moveto(), moverel(), setlinestyle(),
              setwritemode()
 
linerel()

Description   This function draws a line from the current pointer (CP)
              to a point displaced from it by (dx,dy).

Declaration   linerel(int dx, int dy)

Remarks       Denoting the position of the current pointer by (CPx,CPy),
              the line is drawn from this current pointer position to
              (CPx+dx,CPy+dy).

              The line is drawn using the current line style and thickness.
              The line style can be set with the function setlinestyle().
              If that function has not been called, the default line will
              be solid with the thickness if 1 pixel.

              By default the line overwrites the underlying image. However,
              if the function setwritemode() has been called with an argument 
              of XOR_PUT, the line is XORed onto the image -- that is,
              the pixels which are switched on in the underlying image are
              switched off, and those off are switched on. See the description
              of setwritemode() for a complete discussion of the XOR mode.

              The current pointer is moved to (CPx+dx,CPy+dy) after the line
              is drawn.

See also      line(), lineto(), moveto(), moverel(), setlinestyle(), 
              setwritemode()
 
lineto()

Description   This function draws a line from the current pointer (CP)
              to a point (x,y).

Declaration   void lineto(int x, int y)

Remarks       The line is drawn using the current line style and thickness.
              The line style can be set with the function setlinestyle().
              If that function has not been called, the default line will
              be solid with the thickness if 1 pixel.

              By default the line overwrites the underlying image. However,
              if the function setwritemode() has been called with an argument 
              of XOR_PUT, the line is XORed onto the image -- that is,
              the pixels which are switched on in the underlying image are
              switched off, and those off are switched on. See the description
              of SetWriteMode for a complete discussion of the XOR mode.

              The current pointer is moved to (x,y) after the line is drawn.

See also      line(), linerel(), moveto(), moverel(), setlinestyle(), 
              setwritemode()
 
moverel()

Description   This function moves the current pointer to a position displaced
              from it by (dx,dy).

Declaration   void moverel( int dx, int dy)

Remarks       Denoting the current position of the pointer by (CPx, CPy),
              the pointer is moved to (CPx + dx, CPy + dy).

              The related function moveto() moves the current pointer to an
              absolutely specified position.

See also      moveto()
 
moveto()

Description   This function moves the current pointer to a point (x,y).

Declaration   moveto(int x, int y)

Remarks       The related function moverel() moves the pointer relative
              to the current position.

See also      moverel()
 
outtext()

Description   This function writes out a text string to the screen
              at the location of the current pointer (CP).

Declaration   void outtext(char *textstring)

Remarks       The string is written using the current font style, direction,
              size, as set by settextstyle(), with the size possibly modified
              by a call to setusercharsize(). If settextstyle() has not been
              called prior to outtext(), then default values for the style,
              direction, etc. will be used.

              The string is justified with respect to the current pointer
              (CP) according to the justification specified by the last
              call to settextjustify(). If settextjustify() has not been 
              called, the text is left-justified horizontally, and top-
              justified vertically. This means that the current pointer is 
              to the left and below the printed text.

              The current pointer (CP) is updated by outtext() in one case
              only -- when the text direction is horizontal and the text
              is left justified horizontally. In other cases, CP is not
              changed.

              The related procedure outtextxy() writes the text around the
              (x,y) position specified, rather than around the current
              pointer.

              The function gettextsettings can be used to obtain the currently
              active values of the text style and justification, as set by
              settextstyle() and settextjustify(). This is useful when 
              temporary change of settings is desired.

              See the discussion under settextstyle() for a more thorough
              discussion of the font system.

See also      outtextxy(), settextjustify(), gettextsettings(), settextstyle(),
              setusercharsize()
 
outtextxy()

Description   This function writes a text string to the screen
              at the location specified.

Declaration   void outtextxy (int x, int y, char *textstr)

Remarks       The string is written using the current font style, direction,
              size, as set by settextstyle(), with the size possibly modified
              by a call to setusercharsize(). If settextstyle() has not been
              called prior to outtext(), then default values for the style,
              direction, etc. will be used. 

              The string is justified with respect to the current pointer
              (CP) according to the justification specified by the last
              call to settextjustify(). If settextjustify() has not been 
              called, the text is left-justified horizontally, and top-
              justified vertically. This means that the current pointer is 
              to the left and below the printed text.

              The current pointer (CP) is never updated by outtextxy().

              The related procedure outtext() writes the text around the
              the current pointer (CP), rather than around a specified
              position.

              The function gettextsettings() can be used to obtain the 
              currently active values of the text style and justification, 
              as set by settextstyle() and settextjustify(). This is useful 
              when temporary change of settings is desired.

              See the discussion under settextstyle() for a more thorough
              discussion of the font system.

See also      outtext(), settextjustify(), gettextsettings(), settextstyle(),
              setusercharsize()
 
pieslice()

Description   This function draws a circular "pie slice" and fills it
              with the current pattern and color.

Declaration   void pieslice (int xcenter, 
                             int ycenter,
                             int stangle, 
                             int endangle,
                             int radius)

Remarks       The pie slice has a center at (xcenter, ycenter) and has
              radius radius. The pie slice lies between the angles
              stangle and endangle, which are specified in degrees.The
              slice is outlined with a line having the current line
              thickness.

              The endpoints and the center of the arc may be obtained
              by calling the function getarccoords(). This information is
              useful if you want to connect other objects, such as lines,
              to the endpoints of the arc.

              The related function sector() draws an elliptical pie slice.

See also      getarccoords(), sector(), setlinestyle(), arc()
 
putimage()

Description   This function transfers a rectangular block of pixels from
              the memory to a specified location on the screen.

Declaration   void putimage(int  x,
                            int  y,
                            void *bitmap,
                            int  op)

Remarks       The point (x,y) is the UPPER LEFT corner of the region
              on the screen to which the block will be transferred.
              Bitmap is a pointer to the memory block that contains
              the image.  The final parameter, op, selects the transfer 
              mode, i.e., the binary operation used to combine the data in
              the image with the data already on the screen at the target 
              location. 

              The following enumerated types define the operations:

              enum putimage_ops /* BitBlt operators for putimage */
                 {
                    COPY_PUT,         /* MOV */
                    XOR_PUT,          /* XOR */
                    OR_PUT,           /* OR  */
                    AND_PUT,          /* AND */
                    NOT_PUT           /* NOT */
                 }

              As is suggested by the names of these constants, COPY_PUT 
              simply overwrite the image in the target region.
              XOR_PUT XORs the block and the target region; OR_PUT ORs the
              data; AND_PUT ANDs the data; NOT_PUT NOTs the data.

See also      getimage(), imagesize()
 
putpixel()

Description   This function writes a pixel at the position (x, y) on the
              screen, using the color specified in color.

Declaration   putpixel(int x, 
                       int y, 
                       int color)

Remarks       The following colors are defined in graphics.h:
              
              enum COLORS
                 {
                    BLACK,
                    BLUE,
                    GREEN,
                    CYAN,
                    RED,
                    MAGENTA,
                    BROWN,
                    LIGHTGRAY,
                    DARKGRAY,
                    LIGHTBLUE,
                    LIGHTGREEN,
                    LIGHTCYAN,
                    LIGHTRED,
                    LIGHTMAGENTA,
                    YELLOW,
                    WHITE
                 }

See also      getpixel(), bar(), getimage(), putimage()
 
rectangle()

Description   This function draws a rectangle with the upper LEFT corner
              at the point (x1,y1) and the lower RIGHT corner at (x2,y2).

Declaration   void rectangle (int x1,
                              int y1,
                              int x2,
                              int y2)

Remarks       The rectangle is drawn using the current line style and
              thickness. The line style can be set with the function 
              setlinestyle(). If that function has not been called, the
              default line will be solid with the thickness of 1 pixel.

              By default the line overwrites the underlying image. However,
              if the function setwritemode() has been called with an argument 
              of XOR_PUT, the line is XORed onto the image -- that is,
              the pixels which are switched on in the underlying image are
              switched off, and those off are switched on. See the description
              of setwritemode() for a complete discussion of the XOR mode.

See also      setlinestyle(), setwritemode(), bar(), bar3d()
 
restorecrtmode()

Description   Restores the display back to its original settings.

Declaration   void restorecrtmode()

Remarks       restorecrtmode() restores the display back to its original
              settings, before initgraph() has been called.

See also      initgraph(), setgraphmode()
 
sector()

Description   This function draws an elliptical "pie slice" and fills it
              with the current pattern and color.

Declaration   sector(int xcenter, 
                     int ycenter,
                     int stangle, 
                     int endangle,
                     int xradius, 
                     int yradius)

Remarks       The sector has a center at (xcenter, ycenter) and has
              xradius in the horizontal direction and yradius in the 
              vertical direction. The sector lies between the angles
              stangle and endangle, which are specified in degrees.The
              sector is outlined with a line having the current line
              thickness.

              The endpoints and the center of the elliptical arc may be
              obtained by calling the function getarccoords(). This infor-
              mation is useful if you want to connect other objects, such
              as lines, to the endpoints of the arc.

              The related function pieslice() draws a circular "pie slice".

See also      getarccoords(), pieslice(), setlinestyle()
 
setallpalette()

Description   Replaces current color palette with the specified one.

Declaration   void setallpalette(struct palettetype *palette)

Remarks       The following structure is defined in graphics.h to
              describe the palette:

                 struct palettetype
                    {
                       unsigned size;
                       int colors[MAXCOLORS+1];
                    }
              
              size specifies the number of colors used in the current
              palette.  colors is an array containing the color numbers 
              each entry in the palette.  Only the first size entries
              in the array are valid.  If any element is set to -1, the
              corresponding color is not affected.
 
              MAXCOLORS is defined in graphics.h as having a value of 255.

              Number of colors in the palette depends on the graphical 
              adapter and graphical mode being used.

See also      setpalette(), getpalette(), getpalettesize()
 
setaspectratio()

Description   Sets the new aspect ratio.

Declaration   setaspectratio(int xasp,
                             int yasp)

Remarks       This function changes the default aspect ratio used in
              the graphics system to draw various geometric figures.
      
              It can be used to correct aspect ratio of some monitors
              that are not tuned properly.

See also      getaspectratio()
 
setbkcolor() 

Description   This function sets the background color

Declaration   void setbkcolor(int color)

Remarks       The following colors are defined in graphics.h:

              enum COLORS
                 {
                    BLACK,
                    BLUE,
                    GREEN,
                    CYAN,
                    RED,
                    MAGENTA,
                    BROWN,
                    LIGHTGRAY,
                    DARKGRAY,
                    LIGHTBLUE,
                    LIGHTGREEN,
                    LIGHTCYAN,
                    LIGHTRED,
                    LIGHTMAGENTA,
                    YELLOW,
                    WHITE
                 }
       
See also      getbkcolor(), getcolor(), setcolor(), getmaxcolor()
    
setcolor()

Description   This function sets the foreground color.

Declaration   void setcolor (int color)

Remarks       The following colors are defined in graphics.h:

              enum COLORS
                 {
                    BLACK,
                    BLUE,
                    GREEN,
                    CYAN,
                    RED,
                    MAGENTA,
                    BROWN,
                    LIGHTGRAY,
                    DARKGRAY,
                    LIGHTBLUE,
                    LIGHTGREEN,
                    LIGHTCYAN,
                    LIGHTRED,
                    LIGHTMAGENTA,
                    YELLOW,
                    WHITE
                 }

See also      getbkcolor(), getcolor(), setbkcolor(), getmaxcolor()
    
setfillpattern()

Description   This function specifies user-defined fill pattern and color
              to be used for filling regions.

Declaration   void setfillpattern (char *pattern,
                                   int  color)

Remarks       pattern argument is a pointer to a sequence of eight bytes
              where each of the bytes corresponds to eight pixels in
              the pattern being defined.  A pixel is drawn when a corres-
              ponding bit in the pattern byte is set to one.

              color argument selects the color in which the patterns 
              will be drawn.

              The currently active user-defined fill pattern can be obtained
              by calling getfillpattern(). Obtaining the pattern would be
              useful when a temporary change in pattern is desired.

              The fill pattern set by this function is used by the following
              other functions: bar(), bar3d(), fillpoly(), pieslice(), 
              sector(), fillellipse().

See also      setfillstyle()
 
setfillstyle()

Description   This function selects the pattern and color to be used for
              filling regions.

Declaration   setfillstyle(int pattern, 
                           int color)

Remarks       The fill style set by this function is used by the following
              other functions: bar(), bar3d(), fillpoly(), pieslice(), 
              sector(), ellipse().

              The Pattern argument specifies which pattern will be used to
              fill regions. The following enumerated types are defined in 
              graphics.h for specifying patters:

                 enum fill_patterns /* Fill patterns for get/setfillstyle */
                    {
                       EMPTY_FILL,       /* fills area in background color */
                       SOLID_FILL,       /* fills area in solid fill color */
                       LINE_FILL,        /* --- fill                       */
                       LTSLASH_FILL,     /* /// fill                       */
                       SLASH_FILL,       /* /// fill with thick lines      */
                       BKSLASH_FILL,     /* \\\ fill with thick lines      */
                       LTBKSLASH_FILL,   /* \\\ fill                       */
                       HATCH_FILL,       /* light hatch fill               */
                       XHATCH_FILL,      /* heavy cross hatch fill         */
                       INTERLEAVE_FILL,  /* interleaving line fill         */
                       WIDE_DOT_FILL,    /* widely spaced dot fill         */
                       CLOSE_DOT_FILL,   /* closely spaced dot fill        */
                       USER_FILL         /* user defined fill              */
                    }

              Note that the first twelve definitions refer to pre-defined
              patterns, while the last (USER_FILL) selects a user-defined
              pattern, as specified by setfillpattern() function. (If 
              USER_FILL is used and setfillpattern() has not been called, the
              most recently used pattern will be selected.)

              Color selects the color in which the pattern will be drawn.

              The default fill style (used if setfillstyle() and 
              setfillpattern() have not been called) is a solid fill with
              the current foreground color.

              The currently active fill style can be obtained by calling
              getfillsettings(). This is useful if a temporary change
              in pattern is desirable.

See also      setfillpattern(), getfillsettings(), setcolor()
 
setgraphmode()

Description   Resets the system to a new graphics mode.

Declaration   void setgraphmode(int mode)

Remarks       Allows one to change to a different graphics mode after
              the call to initgraph() has been made.

              The following graphics modes are defined in graphics.h:

                 #define G640x200x16        0x0E
		 #define G640x350x16        0x10
		 #define G640x480x16        0x12
		 #define G320x200x256       0x13

		 #define G800x600x16        0x102
		 #define G1024x768x16       0x104

		 #define G640x400x256       0x100
		 #define G640x480x256       0x101
		 #define G800x600x256       0x103
		 #define G1024x768x256      0x105

		 #define GRAPHMONO          0x0f

              When the new graphics mode is set, the screen is cleared
              and all graphics settings, such as CP, palettes and colors
              are reset to their default values.

              restorecrtmode() should be used to set the screen to text mode.

See also      initgraph(), restorecrtmode()
 
setlinestyle()

Description   This function the pattern and thickness used for drawing lines,
              and the thickness used for drawing circles, ellipses, and arcs.

Declaration   void setlinestyle(int linestyle, 
                                unsigned pattern, 
                                int thickness)

Remarks       The following enumerated types are defined for use as linestyle()
              argument:

                 enum line_styles /* Line styles for get/setlinestyle */
                    {
                       SOLID_LINE   = 0,
                       DOTTED_LINE  = 1,
                       CENTER_LINE  = 2,
                       DASHED_LINE  = 3,
                       USERBIT_LINE = 4 /* User defined line style */
                    }

              The first four definitions specify pre-defined line styles. If
              one of the first four definitions is used, the second argument,
              Pattern, is irrelevant, and may have any value. However, if
              USERBIT_LN is used for linestyle, the pattern argument is
              important, and in fact specifies the bit pattern to be used
              for drawing lines. pattern is a 32 bit value, and for every
              bit which is turned on in pattern, a pixel is turned on in the
              line. 

              The final argument, thickness, specifies how thick the line is
              in pixels.  The following enumerated types have been defined
              in graphics.h to specify line thickness:

                 enum line_widths /* Line widths for get/setlinestyle */
                    {
                       NORM_WIDTH  = 1,
                       THICK_WIDTH = 3
                    };

              Lines can be of arbitrary thickness.

              For Circles, Ellipses, and Arcs, the line thickness is used,
              but not the style. Circular and elliptical objects are always
              drawn with solid lines.

              The default line style is a solid line with a thickness of one.

              The currently active line style can be obtained by a call to
              the function getlinesettings(). Obtaining the current line style
              can be useful in temporarily changing the line style.

See also      getlinesettings(), line(), lineto(), linerel()
 
setpalette()

Description   Change one color in the current color palette.

Declaration   void setpalette(int colornum,
                              int color)

Remarks       This function changes entry number colornum in the
              current color palette to the specified value.

	      The following colors are defined in graphics.h:

	         enum COLORS
		    {
		       BLACK,
		       BLUE,
		       GREEN,
		       CYAN,
		       RED,
		       MAGENTA,
		       BROWN,
		       LIGHTGRAY,
		       DARKGRAY,
		       LIGHTBLUE,
		       LIGHTGREEN,
		       LIGHTCYAN,
		       LIGHTRED,
		       LIGHTMAGENTA,
		       YELLOW,
		       WHITE
		    };

              Valid colors depend on the currently selected graphics
              mode and on the graphics adapter being used.

See also      getpalette(), setallpalette(), setrgbpalette()
 
setrgbpalette()

Description   Defines custom colors for VGA and SVGA graphics modes.

Declaration   void setrgbpalette(int colornum,
                                 int red,
                                 int green, 
                                 int blue)

Remarks       colornum is the color number that will be used for the
              newly defined color.  red, green and blue are the component
              colors of the new color.  For SVGA modes, the range for the
              component colors is from 0 to 255.  For VGA modes, it is
              from 0 to 15.  

              Note that only the 6 most significant bits out of the lower 
              byte of the component color are used for color specification.

See also      setpalette(), setallpalette(), getpalette(), getpalettesize()
 
settextjustify()

Description   Sets the horizontal and vertical text justification for text 
              output functions in graphics mode.

Declaration   void settextjustify(int horiz,
                                  int vert)

Remarks       Text is justified either with respect to the current pointer
              (if written with outtext()) or with respect to a specified
              point (if written with outtextxy()).  This function is used
              to specify how the text is justified about these justification
              points.

              The following enumerated type defines the possible text
              justification:

	         enum text_just /* Horizontal and vertical justification */
                                /* for settextjustify */
		   {
		      LEFT_TEXT        = 0,
		      CENTER_TEXT      = 1,
		      RIGHT_TEXT       = 2,

		      BOTTOM_TEXT      = 0,

		      TOP_TEXT         = 2
		   };
                
	      The default justification is LEFT_TEXT horizontally and
              BOTTOM_TEXT vertically.

See also      settextstyle(), gettextsettings(), outtext(), outtextxy()

 
settextstyle()

Description   Sets style, direction and size for the text font used by
              the text output functions.

Declaration   void settextstyle(int font,
                                int direction,
                                int charsize)

Remarks       The following fonts are available and described in graphics.h:

	         enum font_names
		    {
		       DEFAULT_FONT    = 0, /* 8x8 bit mapped font */
		       TRIPLEX_FONT    = 1, /* "Stroked" fonts */
		       SMALL_FONT      = 2,
		       SANS_SERIF_FONT = 3,
		       GOTHIC_FONT     = 4
		    };

              The first font is a 8x8 bit mapped built-in user-modifiabl font.
              The other four are stroked scalable fonts that typically reside
              on the disk and are loaded as needed.  Default font can be
              modified using the function setuserdefchar().  Additional
              stroked fonts can be registered and loaded using 
              installuserfont() function.

              direction can be either horizontal or vertical.  The possible 
              values for direction are defined as follwing in graphics.h:

	         #define HORIZ_DIR        0        /* left to right */
		 #define VERT_DIR         1        /* bottom to top */
              
	      charsize specifies how each character will be magnified when
              it is displayed.  Its function differs between default and
              stroked fonts, as follows:

		1. charsize of 0 can only be used with stroked fonts.
                
		2. When charsize is one, default font is displayed in
                   8x8 pixel rectangle.
          
                3. When charsize is two, default font is displayed in
                   16x16 pixel rectangle.  A maximum of tenfold magnification
                   is allowed.

                4. When charsize is zero, stroked font text is magnified 
                   using either default magnification factor (4), or user-
                   defined character size specified in setusercharsize().

              It is suggested that textheight() and textwidth() should always
              be used to determine the actual text size.

See also      gettextsettings(), installuserfont(), settextjustify(), 
              setusercharsize(), textheight(), textwidth()
 
setusercharsize()

Description   Allows the user to modify character height and width for
              stroked fonts.

Declaration   void setusercharsize(int multx,
                                   int divx,
                                   int multy,
                                   int divy)

Remarks       Arguments to this function are scaling factors by which
              the height and width of the stroked font are scaled.  The
              width is scaled by multx:divx, and the height is scaled by
              multy:divy.

              This function has effect only if settextstyle() has been
              previously called with charsize argument set to zero.

See also      settextstyle(), gettextsetting(), settextjustify()
 
setviewport()

Description   Defines the viewport location and clipping state.

Declaration   setviewport(int left,
                          int top, 
                          int right, 
                          int bottom,
                          int clip)

Remarks       A viewport is a rectangular "window" in the image which
              defines a new location for the coordinate system, and optionally
              (if viewport clipping is on) restricts the active region of
              the screen to the viewport itself.  When graphics is initialized
              the viewport is set to the entire screen.  setviewport() can be
              used to define a new location and size for the viewport and/or
              change the clipping state.  The point (left, top) is the upper
              left corner of the viewport, and (right, bottom) is the lower 
	      right corner.  If clip is set to true (1), viewport clipping
              is enabled.  Note that left, top, right and bottom are always
              relative to the upper left corner of the screen, that is, they
              are independent of the current viewport location.

              Once a viewport has been selected, position arguments for
              every graphics routine (except setviewport(), getviewsettings(),
              getmaxx() and getmaxy()) are relative to the upper left corner
              of the current viewport.  Thus, defining a viewport effectively
              moves the origin of the coordinate system.

              If viewport clipping is enabled, the viewport is the only region
              of the image that is affected by graphics commands.  If viewport
              clipping is not enabled, all positions in the image may be
              affected by graphics commands.  In this case, the only effect of
              defining the viewport is to move the location of the coordinate
              system origin.

              When setviewport() is called, the current pointer (CP) is
              automatically moved to the upper left hand of the new viewport.

              Note that the location of th current pointer is never clipped
              at a viewport boundary, even if clipping is enabled.  Thus it
              is possible to move the CP out of the current viewport.

See also      getviewsettings(), clearviewport()
 
setwritemode()

Description   Specifies whether overwrite mode or XOR mode should be used
              for drawing lines.

Declaration   void setwritemode(int writemode)

Remarks       The following enumeration in graphics.h defines the possible 
              arguments to this function:

	         enum putimage_ops /* BitBlt operators for putimage */
		    {
		       COPY_PUT,         /* MOV */
		       XOR_PUT,          /* XOR */
		       OR_PUT,           /* OR  */
		       AND_PUT,          /* AND */
		       NOT_PUT           /* NOT */
		    };

              Note that only the first two values, COPY_PUT and XOR_PUT
              can be used with this function.

              Presently, setwritemode() affects the following functions:
	      
		line()
		lineto()
		linerel()
		rectange()
		drawpoly()

See also     setlinestyle()
 
textheight()

Description   Returns the current text height in pixels.

Declaration   int textheight(char *string)

Remarks       The text height returned is the height of the tallest character 
              in the specified string.  This height is determined from the
              current font size and multiplication factor.

See also      textwidth(), gettextsettings(), outtext(), outtextxy(),
              settextstyle()
 
textwidth()

Description   Returns the current text width in pixels.

Declaration   int textwidth(char *string)

Remarks       The text width returned is the width of the the specified 
	      string.  This width is determined from the current font size 
	      and multiplication factor.

See also      textheight(), gettextsettings(), outtext(), outtextxy(),
              settextstyle()



