8.4 Functions and procedures

Arc

Declaration:
Procedure Arc (X,Y : Integer; start,stop, radius : Word);
Description:
Arc draws part of a circle with center at (X,Y), radius radius, starting from angle start, stopping at angle stop. These angles are measured counterclockwise.
Errors:
None.
See also:
Circle (205),Ellipse (206) GetArcCoords (207),PieSlice (218), Sector (220)

Bar

Declaration:
Procedure Bar (X1,Y1,X2,Y2 : Integer);
Description:
Draws a rectangle with corners at (X1,Y1) and (X2,Y2) and fills it with the current color and fill-style.
Errors:
None.
See also:
Bar3D (204), Rectangle (219)

Bar3D

Declaration:
Procedure Bar3D (X1,Y1,X2,Y2 : Integer; depth : Word; Top : Boolean);
Description:
Draws a 3-dimensional Bar with corners at (X1,Y1) and (X2,Y2) and fills it with the current color and fill-style. Depth specifies the number of pixels used to show the depth of the bar. If Top is true; then a 3-dimensional top is drawn.
Errors:
None.
See also:
Bar (204), Rectangle (219)

Circle

Declaration:
Procedure Circle (X,Y : Integer; Radius : Word);
Description:
Circle draws part of a circle with center at (X,Y), radius radius.
Errors:
None.
See also:
Ellipse (206),Arc (204) GetArcCoords (207),PieSlice (218), Sector (220)

ClearDevice

Declaration:
Procedure ClearDevice ;
Description:
Clears the graphical screen (with the current background color), and sets the pointer at (0,0)
Errors:
None.
See also:
ClearViewPort (205), SetBkColor (222)

ClearViewPort

Declaration:
Procedure ClearViewPort ;
Description:
Clears the current viewport. The current background color is used as filling color. The pointer is set at (0,0)
Errors:
None.
See also:
ClearDevice (205),SetViewPort (227), SetBkColor (222)

CloseGraph

Declaration:
Procedure CloseGraph ;
Description:
Closes the graphical system, and restores the screen modus which was active before the graphical modus was activated.
Errors:
None.
See also:
InitGraph (215)

DetectGraph

Declaration:
Procedure DetectGraph (Var Driver, Modus : Integer);
Description:
Checks the hardware in the PC and determines the driver and screen-modus to be used. These are returned in Driver and Modus, and can be fed to InitGraph. See the InitGraph for a list of drivers and modi.
Errors:
None.
See also:
InitGraph (215)

DrawPoly

Declaration:
Procedure DrawPoly (NumberOfPoints : Word; Var PolyPoints;
Description:

Draws a polygone with NumberOfPoints corner points, using the current color and line-style. PolyPoints is an array of type PointType.

Errors:
None.
See also:
Bar (204), seepBar3D, Rectangle (219)

Ellipse

Declaration:
Procedure Ellipse (X,Y : Integer; Start,Stop,XRadius,YRadius : Word);
Description:
Ellipse draws part of an ellipse with center at (X,Y). XRadius and Yradius are the horizontal and vertical radii of the ellipse. Start and Stop are the starting and stopping angles of the part of the ellipse. They are measured counterclockwise from the X-axis (3 o’clock is equal to 0 degrees). Only positive angles can be specified.
Errors:
None.
See also:
Arc (204) Circle (205), FillEllipse (206)

FillEllipse

Declaration:
Procedure FillEllipse (X,Y : Integer; Xradius,YRadius: Word);
Description:
Ellipse draws an ellipse with center at (X,Y). XRadius and Yradius are the horizontal and vertical radii of the ellipse. The ellipse is filled with the current color and fill-style.
Errors:
None.
See also:
Arc (204) Circle (205), GetArcCoords (207),PieSlice (218), Sector (220)

FillPoly

Declaration:
Procedure FillPoly (NumberOfPoints : Word; Var PolyPoints);
Description:

Draws a polygone with NumberOfPoints corner points and fills it using the current color and line-style. PolyPoints is an array of type PointType.

Errors:
None.
See also:
Bar (204), seepBar3D, Rectangle (219)

FloodFill

Declaration:
Procedure FloodFill (X,Y : Integer; BorderColor : Word);
Description:

Fills the area containing the point (X,Y), bounded by the color BorderColor.

Errors:
None
See also:
SetColor (222), SetBkColor (222)

GetArcCoords

Declaration:
Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
Description:
GetArcCoords returns the coordinates of the latest Arc or Ellipse call.
Errors:
None.
See also:
Arc (204), Ellipse (206)

GetAspectRatio

Declaration:
Procedure GetAspectRatio (Var Xasp,Yasp : Word);
Description:
GetAspectRatio determines the effective resolution of the screen. The aspect ration can the be calculated as Xasp/Yasp.
Errors:
None.
See also:
InitGraph (215),SetAspectRatio (221)

GetBkColor

Declaration:
Function GetBkColor : Word;
Description:
GetBkColor returns the current background color (the palette entry).
Errors:
None.
See also:
GetColor (208),SetBkColor (222)

GetColor

Declaration:
Function GetColor : Word;
Description:
GetColor returns the current drawing color (the palette entry).
Errors:
None.
See also:
GetColor (208),SetBkColor (222)

GetDefaultPalette

Declaration:
Procedure GetDefaultPalette (Var Palette : PaletteType);
Description:
Returns the current palette in Palette.
Errors:
None.
See also:
GetColor (208), GetBkColor (208)

GetDriverName

Declaration:
Function GetDriverName : String;
Description:
GetDriverName returns a string containing the name of the current driver.
Errors:
None.
See also:
GetModeName (211), InitGraph (215)

GetFillPattern

Declaration:
Procedure GetFillPattern (Var FillPattern : FillPatternType);
Description:
GetFillPattern returns an array with the current fill-pattern in FillPattern
Errors:
None
See also:
SetFillPattern (222)

GetFillSettings

Declaration:
Procedure GetFillSettings (Var FillInfo : FillSettingsType);
Description:
GetFillSettings returns the current fill-settings in FillInfo
Errors:
None.
See also:
SetFillPattern (222)

GetGraphMode

Declaration:
Function GetGraphMode : Integer;
Description:
GetGraphMode returns the current graphical modus
Errors:
None.
See also:
InitGraph (215)

GetImage

Declaration:
Procedure GetImage (X1,Y1,X2,Y2 : Integer, Var Bitmap;
Description:
GetImage Places a copy of the screen area (X1,Y1) to X2,Y2 in BitMap
Errors:
Bitmap must have enough room to contain the image.
See also:
ImageSize (215), PutImage (219)

GetLineSettings

Declaration:
Procedure GetLineSettings (Var LineInfo : LineSettingsType);
Description:
GetLineSettings returns the current Line settings in LineInfo
Errors:
None.
See also:
SetLineStyle (224)

GetMaxColor

Declaration:
Function GetMaxColor : Word;
Description:
GetMaxColor returns the maximum color-number which can be set with SetColor. Contrary to Turbo Pascal, this color isn’t always guaranteed to be white (for instance in 256+ color modes).
Errors:
None.
See also:
SetColor (222), GetPaletteSize (212)

GetMaxMode

Declaration:
Function GetMaxMode : Word;
Description:
GetMaxMode returns the highest modus for the current driver.
Errors:
None.
See also:
InitGraph (215)

GetMaxX

Declaration:
Function GetMaxX : Word;
Description:
GetMaxX returns the maximum horizontal screen length
Errors:
None.
See also:
GetMaxY (211)

GetMaxY

Declaration:
Function GetMaxY : Word;
Description:
GetMaxY returns the maximum number of screen lines
Errors:
None.
See also:
GetMaxY (211)

GetModeName

Declaration:
Function GetModeName (Var modus : Integer) : String;
Description:

Returns a string with the name of modus Modus

Errors:
None.
See also:
GetDriverName (209), InitGraph (215)

GetModeRange

Declaration:
Procedure GetModeRange (Driver : Integer;
LoModus, HiModus: Integer);
Description:
GetModeRange returns the Lowest and Highest modus of the currently installed driver. If no modes are supported for this driver, HiModus will be -1.
Errors:
None.
See also:
InitGraph (215)

GetPalette

Declaration:
Procedure GetPalette (Var Palette : PaletteType);
Description:
GetPalette returns in Palette the current palette.
Errors:
None.
See also:
GetPaletteSize (212), SetPalette (224)

GetPaletteSize

Declaration:
Function GetPaletteSize : Word;
Description:
GetPaletteSize returns the maximum number of entries in the current palette.
Errors:
None.
See also:
GetPalette (212), SetPalette (224)

GetPixel

Declaration:
Function GetPixel (X,Y : Integer) : Word;
Description:
GetPixel returns the color of the point at (X,Y)
Errors:
None.
See also:

GetTextSettings

Declaration:
Procedure GetTextSettings (Var TextInfo : TextSettingsType);
Description:
GetTextSettings returns the current text style settings : The font, direction, size and placement as set with SetTextStyle and SetTextJustify
Errors:
None.
See also:
SetTextStyle (225), SetTextJustify (225)

GetViewSettings

Declaration:
Procedure GetViewSettings (Var ViewPort : ViewPortType);
Description:
GetViewSettings returns the current viewport and clipping settings in ViewPort.
Errors:
None.
See also:
SetViewPort (227)

GetX

Declaration:
Function GetX : Integer;
Description:
GetX returns the X-coordinate of the current position of the graphical pointer
Errors:
None.
See also:
GetY (213)

GetY

Declaration:
Function GetY : Integer;
Description:
GetY returns the Y-coordinate of the current position of the graphical pointer
Errors:
None.
See also:
GetX (213)

GraphDefaults

Declaration:
Procedure GraphDefaults ;
Description:
GraphDefaults resets all settings for viewport, palette, foreground and background pattern, line-style and pattern, filling style, filling color and pattern, font, text-placement and text size.
Errors:
None.
See also:
SetViewPort (227), SetFillStyle (222), SetColor (222), SetBkColor (222), SetLineStyle (224)

GraphErrorMsg

Declaration:
Function GraphErrorMsg (ErrorCode : Integer) : String;
Description:
GraphErrorMsg returns a string describing the error Errorcode. This string can be used to let the user know what went wrong.
Errors:
None.
See also:
GraphResult (214)

GraphResult

Declaration:
Function GraphResult : Integer;
Description:
GraphResult returns an error-code for the last graphical operation. If the returned value is zero, all went well. A value different from zero means an error has occurred. besides all operations which draw something on the screen, the following procedures also can produce a GraphResult different from zero:
Errors:
None.
See also:
GraphErrorMsg (214)

ImageSize

Declaration:
Function ImageSize (X1,Y1,X2,Y2 : Integer) : Word;
Description:
ImageSize returns the number of bytes needed to store the image in the rectangle defined by (X1,Y1) and (X2,Y2).
Errors:
None.
See also:
GetImage (210)

InitGraph

Declaration:
Procedure InitGraph (var GraphDriver,GraphModus : integer;
const PathToDriver : string);
Description:

InitGraph initializes the graph package. GraphDriver has two valid values: GraphDriver=0 which performs an auto detect and initializes the highest possible mode with the most colors. 1024x768x64K is the highest possible resolution supported by the driver, if you need a higher resolution, you must edit MODES.PPI. If you need another mode, then set GraphDriver to a value different from zero and graphmode to the mode you wish (VESA modes where 640x480x256 is 101h etc.). PathToDriver is only needed, if you use the BGI fonts from Borland.

Errors:
None.
See also:
Introduction, (page 190), DetectGraph (206), CloseGraph (205), GraphResult (214)

Example:

 var
    gd,gm : integer;
    PathToDriver : string;
 begin
    gd:=detect; { highest possible resolution }
    gm:=0; { not needed, auto detection }
    PathToDriver:='C:\PP\BGI'; { path to BGI fonts,
                                 drivers aren't needed }
    InitGraph(gd,gm,PathToDriver);
    if GraphResult<>grok then
      halt; ..... { whatever you need }
    CloseGraph; { restores the old graphics mode }
 end.

InstallUserDriver

Declaration:
Function InstallUserDriver (DriverPath : String;
AutoDetectPtr: Pointer) : Integer;
Description:
InstallUserDriver adds the device-driver DriverPath to the list of .BGI drivers. AutoDetectPtr is a pointer to a possible auto-detect function.
Errors:
None.
See also:
InitGraph (215), InstallUserFont (216)

InstallUserFont

Declaration:
Function InstallUserFont (FontPath : String) : Integer;
Description:
InstallUserFont adds the font in FontPath to the list of fonts of the .BGI system.
Errors:
None.
See also:
InitGraph (215), InstallUserDriver (216)

Line

Declaration:
Procedure Line (X1,Y1,X2,Y2 : Integer);
Description:
Line draws a line starting from (X1,Y1 to (X2,Y2), in the current line style and color. The current position is put to (X2,Y2)
Errors:
None.
See also:
LineRel (217),LineTo (217)

LineRel

Declaration:
Procedure LineRel (DX,DY : Integer);
Description:
LineRel draws a line starting from the current pointer position to the point(DX,DY, relative to the current position, in the current line style and color. The Current Position is set to the endpoint of the line.
Errors:
None.
See also:
Line (216), LineTo (217)

LineTo

Declaration:
Procedure LineTo (DX,DY : Integer);
Description:
LineTo draws a line starting from the current pointer position to the point(DX,DY, relative to the current position, in the current line style and color. The Current position is set to the end of the line.
Errors:
None.
See also:
LineRel (217),Line (216)

MoveRel

Declaration:
Procedure MoveRel (DX,DY : Integer;
Description:
MoveRel moves the pointer to the point (DX,DY), relative to the current pointer position
Errors:
None.
See also:
MoveTo (218)

MoveTo

Declaration:
Procedure MoveTo (X,Y : Integer;
Description:
MoveTo moves the pointer to the point (X,Y).
Errors:
None.
See also:
MoveRel (217)

OutText

Declaration:
Procedure OutText (Const TextString : String);
Description:
OutText puts TextString on the screen, at the current pointer position, using the current font and text settings. The current position is moved to the end of the text.
Errors:
None.
See also:
OutTextXY (218)

OutTextXY

Declaration:
Procedure OutTextXY (X,Y : Integer; Const TextString : String);
Description:
OutText puts TextString on the screen, at position (X,Y), using the current font and text settings. The current position is moved to the end of the text.
Errors:
None.
See also:
OutText (218)

PieSlice

Declaration:
Procedure PieSlice (X,Y : Integer;
Start,Stop,Radius : Word);
Description:
PieSlice draws and fills a sector of a circle with center (X,Y) and radius Radius, starting at angle Start and ending at angle Stop.
Errors:
None.
See also:
Arc (204), Circle (205), Sector (220)

PutImage

Declaration:
Procedure PutImage (X1,Y1 : Integer; Var Bitmap; How : word) ;
Description:
PutImage Places the bitmap in Bitmap on the screen at (X1,Y1). How determines how the bitmap will be placed on the screen. Possible values are :
Errors:
None
See also:
ImageSize (215),GetImage (210)

PutPixel

Declaration:
Procedure PutPixel (X,Y : Integer; Color : Word);
Description:
Puts a point at (X,Y) using color Color
Errors:
None.
See also:
GetPixel (212)

Rectangle

Declaration:
Procedure Rectangle (X1,Y1,X2,Y2 : Integer);
Description:
Draws a rectangle with corners at (X1,Y1) and (X2,Y2), using the current color and style.
Errors:
None.
See also:
Bar (204), Bar3D (204)

RegisterBGIDriver

Declaration:
Function RegisterBGIDriver (Driver : Pointer) : Integer;
Description:
Registers a user-defined BGI driver
Errors:
None.
See also:
InstallUserDriver (216), RegisterBGIFont (220)

RegisterBGIFont

Declaration:
Function RegisterBGIFont (Font : Pointer) : Integer;
Description:
Registers a user-defined BGI driver
Errors:
None.
See also:
InstallUserFont (216), RegisterBGIDriver (220)

RestoreCRTMode

Declaration:
Procedure RestoreCRTMode ;
Description:
Restores the screen modus which was active before the graphical modus was started.

To get back to the graph mode you were last in, you can use SetGraphMode(GetGraphMode)

Errors:
None.
See also:
InitGraph (215)

Sector

Declaration:
Procedure Sector (X,Y : Integer;
Start,Stop,XRadius,YRadius : Word);
Description:
Sector draws and fills a sector of an ellipse with center (X,Y) and radii XRadius and YRadius, starting at angle Start and ending at angle Stop.
Errors:
None.
See also:
Arc (204), Circle (205), PieSlice (218)

SetActivePage

Declaration:
Procedure SetActivePage (Page : Word);
Description:
Sets Page as the active page for all graphical output.
Errors:
None.
See also:

SetAllPallette

Declaration:
Procedure SetAllPallette (Var Palette);
Description:
Sets the current palette to Palette. Palette is an untyped variable, usually pointing to a record of type PaletteType
Errors:
None.
See also:
GetPalette (212)

SetAspectRatio

Declaration:
Procedure SetAspectRatio (Xasp,Yasp : Word);
Description:
Sets the aspect ratio of the current screen to Xasp/Yasp.
Errors:
None
See also:
InitGraph (215), GetAspectRatio (208)

SetBkColor

Declaration:
Procedure SetBkColor (Color : Word);
Description:
Sets the background color to Color.
Errors:
None.
See also:
GetBkColor (208), SetColor (222)

SetColor

Declaration:
Procedure SetColor (Color : Word);
Description:
Sets the foreground color to Color.
Errors:
None.
See also:
GetColor (208), SetBkColor (222)

SetFillPattern

Declaration:
Procedure SetFillPattern (FillPattern : FillPatternType,
Color : Word);
Description:
SetFillPattern sets the current fill-pattern to FillPattern, and the filling color to Color The pattern is an 8x8 raster, corresponding to the 64 bits in FillPattern.
Errors:
None
See also:
GetFillPattern (209), SetFillStyle (222)

SetFillStyle

Declaration:
Procedure SetFillStyle (Pattern,Color : word);
Description:
SetFillStyle sets the filling pattern and color to one of the predefined filling patterns. Pattern can be one of the following predefined constants :
Errors:
None.
See also:
SetFillPattern (222)

SetGraphBufSize

Declaration:
Procedure SetGraphBufSize (BufSize : Word);
Description:
SetGraphBufSize is a dummy function which does not do anything; it is no longer needed.
Errors:
None.
See also:

SetGraphMode

Declaration:
Procedure SetGraphMode (Mode : Integer);
Description:
SetGraphMode sets the graphical mode and clears the screen.
Errors:
None.
See also:
InitGraph (215)

SetLineStyle

Declaration:
Procedure SetLineStyle (LineStyle,Pattern,Width : Word);
Description:
SetLineStyle sets the drawing style for lines. You can specify a LineStyle which is one of the following pre-defined constants:

If UserBitln is specified then Pattern contains the bit pattern. In all another cases, Pattern is ignored. The parameter Width indicates how thick the line should be. You can specify one of the following pre-defined constants:

Errors:
None.
See also:
GetLineSettings (210)

SetPalette

Declaration:
Procedure SetPalette (ColorNr : Word; NewColor : ShortInt);
Description:
SetPalette changes the ColorNr-th entry in the palette to NewColor
Errors:
None.
See also:
SetAllPallette (221),SetRGBPalette (225)

SetRGBPalette

Declaration:
Procedure SetRGBPalette (ColorNr,Red,Green,Blue : Integer);
Description:
SetRGBPalette sets the ColorNr-th entry in the palette to the color with RGB-values Red, Green Blue.
Errors:
None.
See also:
SetAllPallette (221), SetPalette (224)

SetTextJustify

Declaration:
Procedure SetTextJustify (Horizontal,Vertical : Word);
Description:
SetTextJustify controls the placement of new text, relative to the (graphical) cursor position. Horizontal controls horizontal placement, and can be one of the following pre-defined constants:

Vertical controls the vertical placement of the text, relative to the (graphical) cursor position. Its value can be one of the following pre-defined constants :

Errors:
None.
See also:
OutText (218), OutTextXY (218)

SetTextStyle

Declaration:
Procedure SetTextStyle (Font,Direction,Magnitude : Word);
Description:
SetTextStyle controls the style of text to be put on the screen. pre-defined constants for Font are:
 DefaultFont   = 0;
 TriplexFont   = 1;
 SmallFont     = 2;
 SansSerifFont = 3;
 GothicFont    = 4;
 ScriptFont    = 5;
 SimpleFont    = 6;
 TSCRFont      = 7;
 LCOMFont      = 8;
 EuroFont      = 9;
 BoldFont      = 10;
Pre-defined constants for Direction are :
Errors:
None.
See also:
GetTextSettings (213)

SetUserCharSize

Declaration:
Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
Description:
Sets the width and height of vector-fonts. The horizontal size is given by Xasp1/Xasp2, and the vertical size by Yasp1/Yasp2.
Errors:
None.
See also:
SetTextStyle (225)

SetViewPort

Declaration:
Procedure SetViewPort (X1,Y1,X2,Y2 : Integer; Clip : Boolean);
Description:
Sets the current graphical viewport (window) to the rectangle defined by the top-left corner (X1,Y1) and the bottom-right corner (X2,Y2). If Clip is true, anything drawn outside the viewport (window) will be clipped (i.e. not drawn). Coordinates specified after this call are relative to the top-left corner of the viewport.
Errors:
None.
See also:
GetViewSettings (213)

SetVisualPage

Declaration:
Procedure SetVisualPage (Page : Word);
Description:
SetVisualPage sets the video page to page number Page.
Errors:
None
See also:
SetActivePage (221)

SetWriteMode

Declaration:
Procedure SetWriteMode (Mode : Integer);
Description:
SetWriteMode controls the drawing of lines on the screen. It controls the binary operation used when drawing lines on the screen. Mode can be one of the following pre-defined constants:
Errors:
None.
See also:

TextHeight

Declaration:
Function TextHeight (S : String) : Word;
Description:
TextHeight returns the height (in pixels) of the string S in the current font and text-size.
Errors:
None.
See also:
TextWidth (229)

TextWidth

Declaration:
Function TextWidth (S : String) : Word;
Description:
TextHeight returns the width (in pixels) of the string S in the current font and text-size.
Errors:
None.
See also:
TextHeight (228)