123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491 |
- %
- % $Id$
- % This file is part of the FPC documentation.
- % Copyright (C) 1997, by Michael Van Canneyt
- %
- % The FPC documentation is free text; you can redistribute it and/or
- % modify it under the terms of the GNU Library General Public License as
- % published by the Free Software Foundation; either version 2 of the
- % License, or (at your option) any later version.
- %
- % The FPC Documentation is distributed in the hope that it will be useful,
- % but WITHOUT ANY WARRANTY; without even the implied warranty of
- % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- % Library General Public License for more details.
- %
- % You should have received a copy of the GNU Library General Public
- % License along with the FPC documentation; see the file COPYING.LIB. If not,
- % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- % Boston, MA 02111-1307, USA.
- %
- % Documentation for the 'Graph' unit of Free Pascal.
- % Michael Van Canneyt, July 1997
- \chapter{The GRAPH unit.}
- \FPCexampledir{graphex}
- This document describes the \var{GRAPH} unit for Free Pascal, for all
- platforms. The unit was first written for \dos by Florian kl\"ampfl, but was
- later completely rewritten by Carl-Eric Codere to be completely portable.
- This chapter is divided in 4 sections.
- \begin{itemize}
- \item The first section gives an introduction to the graph unit.
- \item The second section lists the pre-defined constants, types and variables.
- \item The second section describes the functions which appear in the
- interface part of the \file{GRAPH} unit.
- \item The last part describes some system-specific issues.
- \end{itemize}
- \section{Introduction}
- \label{se:Introduction}
- \subsection{Requirements}
- The unit Graph exports functions and procedures for graphical output.
- It requires at least a VGA-compatible Card or a VGA-Card with software-driver
- (min. \textbf{512Kb} video memory).
- \subsection{A word about mode selection}
- The graph unit was implemented for compatibility with the old \tp graph
- unit. For this reason, the mode constants as they were defined in the
- \tp graph unit are retained.
- However, since
- \begin{enumerate}
- \item Video cards have evolved very much
- \item Free Pascal runs on multiple platforms
- \end{enumerate}
- it was decided to implement new mode and graphic driver constants,
- which are more independent of the specific platform the program runs on.
- In this section we give a short explanation of the new mode system. the
- following drivers were defined:
- \begin{verbatim}
- D1bit = 11;
- D2bit = 12;
- D4bit = 13;
- D6bit = 14; { 64 colors Half-brite mode - Amiga }
- D8bit = 15;
- D12bit = 16; { 4096 color modes HAM mode - Amiga }
- D15bit = 17;
- D16bit = 18;
- D24bit = 19; { not yet supported }
- D32bit = 20; { not yet supported }
- D64bit = 21; { not yet supported }
- lowNewDriver = 11;
- highNewDriver = 21;
- \end{verbatim}
- Each of these drivers specifies a desired color-depth.
- The following modes have been defined:
- \begin{verbatim}
- detectMode = 30000;
- m320x200 = 30001;
- m320x256 = 30002; { amiga resolution (PAL) }
- m320x400 = 30003; { amiga/atari resolution }
- m512x384 = 30004; { mac resolution }
- m640x200 = 30005; { vga resolution }
- m640x256 = 30006; { amiga resolution (PAL) }
- m640x350 = 30007; { vga resolution }
- m640x400 = 30008;
- m640x480 = 30009;
- m800x600 = 30010;
- m832x624 = 30011; { mac resolution }
- m1024x768 = 30012;
- m1280x1024 = 30013;
- m1600x1200 = 30014;
- m2048x1536 = 30015;
- lowNewMode = 30001;
- highNewMode = 30015;
- \end{verbatim}
- These modes start at 30000 because Borland specified that the mode number
- should be ascending with increasing X resolution, and the new constants
- shouldn't interfere with the old ones.
- The above constants can be used to set a certain color depth and resultion,
- as demonstrated in the following example:
- \FPCexample{inigraph1}
- If other modes than the ones above are supported by the graphics card,
- you will not be able to select them with this mechanism.
- For this reason, there is also a 'dynamic' mode number, which is assigned at
- run-time. This number increases with increasing X resolution. It can be
- queried with the \var{getmoderange} call. This call will return the range
- of modes which are valid for a certain graphics driver. The numbers are
- guaranteed to be consecutive, and can be used to search for a certain
- resolution, as in the following example:
- \FPCexample{inigraph2}
- Thus, the \var{getmoderange} function can be used to detect all available
- modes and drivers, as in the following example:
- \FPCexample{modrange}
- \section{Constants, Types and Variables}
- \subsection{Types}
- \begin{verbatim}
- ArcCoordsType = record
- X,Y,Xstart,Ystart,Xend,Yend : Integer;
- end;
- FillPatternType = Array [1..8] of Byte;
- FillSettingsType = Record
- Pattern,Color : Word
- end;
- LineSettingsType = Record
- LineStyle,Pattern, Width : Word;
- end;
- PaletteType = Record
- Size : Byte;
- Colors : array[0..MAxColor] of shortint;
- end;
- PointType = Record
- X,Y : Integer;
- end;
- TextSettingsType = Record
- Font,Direction, CharSize, Horiz, Vert : Word
- end;
- ViewPortType = Record
- X1,Y1,X2,Y2 : Integer;
- Clip : Boolean
- end;
- \end{verbatim}
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Functions and procedures by category
- \section{Function list by category}
- What follows is a listing of the available functions, grouped by category.
- For each function there is a reference to the page where you can find the
- function.
- \subsection{Initialization}
- Initialization of the graphics screen.
- \begin{funclist}
- \procref{ClearDevice}{Empty the graphics screen}
- \procref{CloseGraph}{Finish drawing session, return to text mode}
- \procref{DetectGraph}{Detect graphical modes}
- \procref{GetAspectRatio}{Get aspect ratio of screen}
- \procref{GetModeRange}{Get range of valid modes for current driver}
- \procref{GraphDefaults}{Set defaults}
- \funcref{GetDriverName}{Return name of graphical driver}
- \funcref{GetGraphMode}{Return current or last used graphics mode}
- \funcref{GetMaxMode}{Get maximum mode for current driver}
- \funcref{GetModeName}{Get name of current mode}
- \funcref{GraphErrorMsg}{String representation of graphical error}
- \funcref{GraphResult}{Result of last drawing operation}
- \procref{InitGraph}{Initialize graphics drivers}
- \funcref{InstallUserDriver}{Install a new driver}
- \funcref{RegisterBGIDriver}{Register a new driver}
- \procref{RestoreCRTMode}{Go back to text mode}
- \procref{SetGraphBufSize}{Set buffer size for graphical operations}
- \procref{SetGraphMode}{Set graphical mode}
- \end{funclist}
- \subsection{screen management}
- General drawing screen management functions.
- \begin{funclist}
- \procref{ClearViewPort}{Clear the current viewport}
- \procref{GetImage}{Copy image from screen to memory}
- \funcref{GetMaxX}{Get maximum X coordinate}
- \funcref{GetMaxY}{Get maximum Y coordinate}
- \funcref{GetX}{Get current X position}
- \funcref{GetY}{Get current Y position}
- \funcref{ImageSize}{Get size of selected image}
- \procref{GetViewSettings}{Get current viewport settings}
- \procref{PutImage}{Copy image from memory to screen}
- \procref{SetActivePage}{Set active video page}
- \procref{SetAspectRatio}{Set aspect ratio for drawing routines}
- \procref{SetViewPort}{Set current viewport}
- \procref{SetVisualPage}{Set visual page}
- \procref{SetWriteMode}{Set write mode for screen operations}
- \end{funclist}
- \subsection{Color management}
- All functions related to color management.
- \begin{funclist}
- \funcref{GetBkColor}{Get current background color}
- \funcref{GetColor}{Get current foreground color}
- \procref{GetDefaultPalette}{Get default palette entries}
- \funcref{GetMaxColor}{Get maximum valid color}
- \funcref{GetPaletteSize}{Get size of palette for current mode}
- \funcref{GetPixel}{Get color of selected pixel}
- \procref{GetPalette}{Get palette entry}
- \procref{SetAllPallette}{Set all colors in palette}
- \procref{SetBkColor}{Set background color}
- \procref{SetColor}{Set foreground color}
- \procref{SetPalette}{Set palette entry}
- \procref{SetRGBPalette}{Set palette entry with RGB values}
- \end{funclist}
- \subsection{Drawing primitives}
- Functions for simple drawing.
- \begin{funclist}
- \procref{Arc}{Draw an arc}
- \procref{Circle}{Draw a complete circle}
- \procref{DrawPoly}{Draw a polygone with N points}
- \procref{Ellipse}{Draw an ellipse}
- \procref{GetArcCoords}{Get arc coordinates}
- \procref{GetLineSettings}{Get current line drawing settings}
- \procref{Line}{Draw line between 2 points}
- \procref{LineRel}{Draw line relative to current position}
- \procref{LineTo}{Draw line from current position to absolute position}
- \procref{MoveRel}{Move cursor relative to current position}
- \procref{MoveTo}{Move cursor to absolute position}
- \procref{PieSlice}{Draw a pie slice}
- \procref{PutPixel}{Draw 1 pixel}
- \procref{Rectangle}{Draw a non-filled rectangle}
- \procref{Sector}{Draw a sector}
- \procref{SetLineStyle}{Set current line drawing style}
- \end{funclist}
- \subsection{Filled drawings}
- Functions for drawing filled regions.
- \begin{funclist}
- \procref{Bar3D}{Draw a filled 3D-style bar}
- \procref{Bar}{Draw a filled rectangle}
- \procref{FloodFill}{Fill starting from coordinate}
- \procref{FillEllipse}{Draw a filled ellipse}
- \procref{FillPoly}{Draw a filled polygone}
- \procref{GetFillPattern}{Get current fill pattern}
- \procref{GetFillSettings}{Get current fill settings}
- \procref{SetFillPattern}{Set current fill pattern}
- \procref{SetFillStyle}{Set current fill settings}
- \end{funclist}
- \subsection{Text and font handling}
- Functions to set texts on the screen.
- \begin{funclist}
- \procref{GetTextSettings}{Get current text settings}
- \funcref{InstallUserFont}{Install a new font}
- \procref{OutText}{Write text at current cursor position}
- \procref{OutTextXY}{Write text at coordinates X,Y}
- \funcref{RegisterBGIFont}{Register a new font}
- \procref{SetTextJustify}{Set text justification}
- \procref{SetTextStyle}{Set text style}
- \procref{SetUserCharSize}{Set text size}
- \funcref{TextHeight}{Calculate height of text}
- \funcref{TextWidth}{Calculate width of text}
- \end{funclist}
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Functions and procedures
- \section{Functions and procedures}
- \begin{procedure}{Arc}
- \Declaration
- Procedure Arc (X,Y : Integer; start,stop, radius : Word);
- \Description
- \var{Arc} draws part of a circle with center at \var{(X,Y)}, radius
- \var{radius}, starting from angle \var{start}, stopping at angle \var{stop}.
- These angles are measured
- counterclockwise.
- \Errors
- None.
- \SeeAlso
- \seep{Circle},\seep{Ellipse}
- \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
- \end{procedure}
- \begin{procedure}{Bar}
- \Declaration
- Procedure Bar (X1,Y1,X2,Y2 : Integer);
- \Description
- Draws a rectangle with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
- and fills it with the current color and fill-style.
- \Errors
- None.
- \SeeAlso
- \seep{Bar3D},
- \seep{Rectangle}
- \end{procedure}
- \begin{procedure}{Bar3D}
- \Declaration
- Procedure Bar3D (X1,Y1,X2,Y2 : Integer; depth : Word; Top : Boolean);
- \Description
- Draws a 3-dimensional Bar with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
- and fills it with the current color and fill-style.
- \var{Depth} specifies the number of pixels used to show the depth of the
- bar.
- If \var{Top} is true; then a 3-dimensional top is drawn.
- \Errors
- None.
- \SeeAlso
- \seep{Bar}, \seep{Rectangle}
- \end{procedure}
- \begin{procedure}{Circle}
- \Declaration
- Procedure Circle (X,Y : Integer; Radius : Word);
- \Description
- \var{Circle} draws part of a circle with center at \var{(X,Y)}, radius
- \var{radius}.
- \Errors
- None.
- \SeeAlso
- \seep{Ellipse},\seep{Arc}
- \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
- \end{procedure}
- \begin{procedure}{ClearDevice}
- \Declaration
- Procedure ClearDevice ;
- \Description
- Clears the graphical screen (with the current
- background color), and sets the pointer at \var{(0,0)}
- \Errors
- None.
- \SeeAlso
- \seep{ClearViewPort}, \seep{SetBkColor}
- \end{procedure}
- \begin{procedure}{ClearViewPort}
- \Declaration
- Procedure ClearViewPort ;
- \Description
- Clears the current viewport. The current background color is used as filling
- color. The pointer is set at
- \var{(0,0)}
- \Errors
- None.
- \SeeAlso
- \seep{ClearDevice},\seep{SetViewPort}, \seep{SetBkColor}
- \end{procedure}
- \begin{procedure}{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.
- \SeeAlso
- \seep{InitGraph}
- \end{procedure}
- \begin{procedure}{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 \var{Driver} and \var{Modus}, and can be fed
- to \var{InitGraph}.
- See the \var{InitGraph} for a list of drivers and modi.
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}
- \end{procedure}
- \begin{procedure}{DrawPoly}
- \Declaration
- Procedure DrawPoly (NumberOfPoints : Word; Var PolyPoints;
- \Description
- Draws a polygone with \var{NumberOfPoints} corner points, using the
- current color and line-style. PolyPoints is an array of type \var{PointType}.
- \Errors
- None.
- \SeeAlso
- \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
- \end{procedure}
- \begin{procedure}{Ellipse}
- \Declaration
- Procedure Ellipse (X,Y : Integer; Start,Stop,XRadius,YRadius : Word);
- \Description
- \var{Ellipse} draws part of an ellipse with center at \var{(X,Y)}.
- \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
- ellipse. \var{Start} and \var{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.
- \SeeAlso
- \seep{Arc} \seep{Circle}, \seep{FillEllipse}
- \end{procedure}
- \begin{procedure}{FillEllipse}
- \Declaration
- Procedure FillEllipse (X,Y : Integer; Xradius,YRadius: Word);
- \Description
- \var{Ellipse} draws an ellipse with center at \var{(X,Y)}.
- \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
- ellipse. The ellipse is filled with the current color and fill-style.
- \Errors
- None.
- \SeeAlso
- \seep{Arc} \seep{Circle},
- \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
- \end{procedure}
- \begin{procedure}{FillPoly}
- \Declaration
- Procedure FillPoly (NumberOfPoints : Word; Var PolyPoints);
- \Description
- Draws a polygone with \var{NumberOfPoints} corner points and fills it
- using the current color and line-style.
- PolyPoints is an array of type \var{PointType}.
- \Errors
- None.
- \SeeAlso
- \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
- \end{procedure}
- \begin{procedure}{FloodFill}
- \Declaration
- Procedure FloodFill (X,Y : Integer; BorderColor : Word);
- \Description
- Fills the area containing the point \var{(X,Y)}, bounded by the color
- \var{BorderColor}.
- \Errors
- None
- \SeeAlso
- \seep{SetColor}, \seep{SetBkColor}
- \end{procedure}
- \begin{procedure}{GetArcCoords}
- \Declaration
- Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
- \Description
- \var{GetArcCoords} returns the coordinates of the latest \var{Arc} or
- \var{Ellipse} call.
- \Errors
- None.
- \SeeAlso
- \seep{Arc}, \seep{Ellipse}
- \end{procedure}
- \begin{procedure}{GetAspectRatio}
- \Declaration
- Procedure GetAspectRatio (Var Xasp,Yasp : Word);
- \Description
- \var{GetAspectRatio} determines the effective resolution of the screen. The aspect ration can
- the be calculated as \var{Xasp/Yasp}.
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph},\seep{SetAspectRatio}
- \end{procedure}
- \begin{function}{GetBkColor}
- \Declaration
- Function GetBkColor : Word;
- \Description
- \var{GetBkColor} returns the current background color (the palette
- entry).
- \Errors
- None.
- \SeeAlso
- \seef{GetColor},\seep{SetBkColor}
- \end{function}
- \begin{function}{GetColor}
- \Declaration
- Function GetColor : Word;
- \Description
- \var{GetColor} returns the current drawing color (the palette
- entry).
- \Errors
- None.
- \SeeAlso
- \seef{GetColor},\seep{SetBkColor}
- \end{function}
- \begin{procedure}{GetDefaultPalette}
- \Declaration
- Procedure GetDefaultPalette (Var Palette : PaletteType);
- \Description
- Returns the
- current palette in \var{Palette}.
- \Errors
- None.
- \SeeAlso
- \seef{GetColor}, \seef{GetBkColor}
- \end{procedure}
- \begin{function}{GetDriverName}
- \Declaration
- Function GetDriverName : String;
- \Description
- \var{GetDriverName} returns a string containing the name of the
- current driver.
- \Errors
- None.
- \SeeAlso
- \seef{GetModeName}, \seep{InitGraph}
- \end{function}
- \begin{procedure}{GetFillPattern}
- \Declaration
- Procedure GetFillPattern (Var FillPattern : FillPatternType);
- \Description
- \var{GetFillPattern} returns an array with the current fill-pattern in \var{FillPattern}
- \Errors
- None
- \SeeAlso
- \seep{SetFillPattern}
- \end{procedure}
- \begin{procedure}{GetFillSettings}
- \Declaration
- Procedure GetFillSettings (Var FillInfo : FillSettingsType);
- \Description
- \var{GetFillSettings} returns the current fill-settings in
- \var{FillInfo}
- \Errors
- None.
- \SeeAlso
- \seep{SetFillPattern}
- \end{procedure}
- \begin{function}{GetGraphMode}
- \Declaration
- Function GetGraphMode : Integer;
- \Description
- \var{GetGraphMode} returns the current graphical modus
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}
- \end{function}
- \begin{procedure}{GetImage}
- \Declaration
- Procedure GetImage (X1,Y1,X2,Y2 : Integer, Var Bitmap;
- \Description
- \var{GetImage}
- Places a copy of the screen area \var{(X1,Y1)} to \var{X2,Y2} in \var{BitMap}
- \Errors
- Bitmap must have enough room to contain the image.
- \SeeAlso
- \seef{ImageSize},
- \seep{PutImage}
- \end{procedure}
- \begin{procedure}{GetLineSettings}
- \Declaration
- Procedure GetLineSettings (Var LineInfo : LineSettingsType);
- \Description
- \var{GetLineSettings} returns the current Line settings in
- \var{LineInfo}
- \Errors
- None.
- \SeeAlso
- \seep{SetLineStyle}
- \end{procedure}
- \begin{function}{GetMaxColor}
- \Declaration
- Function GetMaxColor : Word;
- \Description
- \var{GetMaxColor} returns the maximum color-number which can be
- set with \var{SetColor}. Contrary to \tp, this color isn't always
- guaranteed to be white (for instance in 256+ color modes).
- \Errors
- None.
- \SeeAlso
- \seep{SetColor},
- \seef{GetPaletteSize}
- \end{function}
- \begin{function}{GetMaxMode}
- \Declaration
- Function GetMaxMode : Word;
- \Description
- \var{GetMaxMode} returns the highest modus for
- the current driver.
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}
- \end{function}
- \begin{function}{GetMaxX}
- \Declaration
- Function GetMaxX : Word;
- \Description
- \var{GetMaxX} returns the maximum horizontal screen
- length
- \Errors
- None.
- \SeeAlso
- \seef{GetMaxY}
- \end{function}
- \begin{function}{GetMaxY}
- \Declaration
- Function GetMaxY : Word;
- \Description
- \var{GetMaxY} returns the maximum number of screen
- lines
- \Errors
- None.
- \SeeAlso
- \seef{GetMaxY}
- \end{function}
- \begin{function}{GetModeName}
- \Declaration
- Function GetModeName (Var modus : Integer) : String;
- \Description
- Returns a string with the name of modus
- \var{Modus}
- \Errors
- None.
- \SeeAlso
- \seef{GetDriverName}, \seep{InitGraph}
- \end{function}
- \begin{procedure}{GetModeRange}
- \Declaration
- Procedure GetModeRange (Driver : Integer; \\ LoModus, HiModus: Integer);
- \Description
- \var{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.
- \SeeAlso
- \seep{InitGraph}
- \end{procedure}
- \begin{procedure}{GetPalette}
- \Declaration
- Procedure GetPalette (Var Palette : PaletteType);
- \Description
- \var{GetPalette} returns in \var{Palette} the current palette.
- \Errors
- None.
- \SeeAlso
- \seef{GetPaletteSize}, \seep{SetPalette}
- \end{procedure}
- \begin{function}{GetPaletteSize}
- \Declaration
- Function GetPaletteSize : Word;
- \Description
- \var{GetPaletteSize} returns the maximum
- number of entries in the current palette.
- \Errors
- None.
- \SeeAlso
- \seep{GetPalette},
- \seep{SetPalette}
- \end{function}
- \begin{function}{GetPixel}
- \Declaration
- Function GetPixel (X,Y : Integer) : Word;
- \Description
- \var{GetPixel} returns the color
- of the point at \var{(X,Y)}
- \Errors
- None.
- \SeeAlso
- \end{function}
- \begin{procedure}{GetTextSettings}
- \Declaration
- Procedure GetTextSettings (Var TextInfo : TextSettingsType);
- \Description
- \var{GetTextSettings} returns the current text style settings : The font,
- direction, size and placement as set with \var{SetTextStyle} and
- \var{SetTextJustify}
- \Errors
- None.
- \SeeAlso
- \seep{SetTextStyle}, \seep{SetTextJustify}
- \end{procedure}
- \begin{procedure}{GetViewSettings}
- \Declaration
- Procedure GetViewSettings (Var ViewPort : ViewPortType);
- \Description
- \var{GetViewSettings} returns the current viewport and clipping settings in
- \var{ViewPort}.
- \Errors
- None.
- \SeeAlso
- \seep{SetViewPort}
- \end{procedure}
- \begin{function}{GetX}
- \Declaration
- Function GetX : Integer;
- \Description
- \var{GetX} returns the X-coordinate of the current position of
- the graphical pointer
- \Errors
- None.
- \SeeAlso
- \seef{GetY}
- \end{function}
- \begin{function}{GetY}
- \Declaration
- Function GetY : Integer;
- \Description
- \var{GetY} returns the Y-coordinate of the current position of
- the graphical pointer
- \Errors
- None.
- \SeeAlso
- \seef{GetX}
- \end{function}
- \begin{procedure}{GraphDefaults}
- \Declaration
- Procedure GraphDefaults ;
- \Description
- \var{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.
- \SeeAlso
- \seep{SetViewPort}, \seep{SetFillStyle}, \seep{SetColor},
- \seep{SetBkColor}, \seep{SetLineStyle}
- \end{procedure}
- \begin{function}{GraphErrorMsg}
- \Declaration
- Function GraphErrorMsg (ErrorCode : Integer) : String;
- \Description
- \var{GraphErrorMsg}
- returns a string describing the error \var{Errorcode}. This string can be
- used to let the user know what went wrong.
- \Errors
- None.
- \SeeAlso
- \seef{GraphResult}
- \end{function}
- \begin{function}{GraphResult}
- \Declaration
- Function GraphResult : Integer;
- \Description
- \var{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 \var{GraphResult} different from
- zero:
- \begin{itemize}
- \item \seef{InstallUserFont}
- \item \seep{SetLineStyle}
- \item \seep{SetWriteMode}
- \item \seep{SetFillStyle}
- \item \seep{SetTextJustify}
- \item \seep{SetGraphMode}
- \item \seep{SetTextStyle}
- \end{itemize}
- \Errors
- None.
- \SeeAlso
- \seef{GraphErrorMsg}
- \end{function}
- \begin{function}{ImageSize}
- \Declaration
- Function ImageSize (X1,Y1,X2,Y2 : Integer) : Word;
- \Description
- \var{ImageSize} returns
- the number of bytes needed to store the image in the rectangle defined by
- \var{(X1,Y1)} and \var{(X2,Y2)}.
- \Errors
- None.
- \SeeAlso
- \seep{GetImage}
- \end{function}
- \begin{procedure}{InitGraph}
- \Declaration
- Procedure InitGraph (var GraphDriver,GraphModus : integer;\\
- const PathToDriver : string);
- \Description
- \var{InitGraph} initializes the \var{graph} package.
- \var{GraphDriver} has two valid values: \var{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 \file{MODES.PPI}.
- If you need another mode, then set \var{GraphDriver} to a value different
- from zero
- and \var{graphmode} to the mode you wish (VESA modes where 640x480x256
- is \var {101h} etc.).
- \var{PathToDriver} is only needed, if you use the BGI fonts from
- Borland.
- \Errors
- None.
- \SeeAlso
- Introduction, (page \pageref{se:Introduction}),
- \seep{DetectGraph}, \seep{CloseGraph}, \seef{GraphResult}
- \end{procedure}
- Example:
- \begin{verbatim}
- 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.
- \end{verbatim}
- \begin{function}{InstallUserDriver}
- \Declaration
- Function InstallUserDriver (DriverPath : String; \\AutoDetectPtr: Pointer) : Integer;
- \Description
- \var{InstallUserDriver}
- adds the device-driver \var{DriverPath} to the list of .BGI
- drivers. \var{AutoDetectPtr} is a pointer to a possible auto-detect function.
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}, \seef{InstallUserFont}
- \end{function}
- \begin{function}{InstallUserFont}
- \Declaration
- Function InstallUserFont (FontPath : String) : Integer;
- \Description
- \var{InstallUserFont} adds the font in \var{FontPath} to the list of fonts
- of the .BGI system.
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}, \seef{InstallUserDriver}
- \end{function}
- \begin{procedure}{Line}
- \Declaration
- Procedure Line (X1,Y1,X2,Y2 : Integer);
- \Description
- \var{Line} draws a line starting from
- \var{(X1,Y1} to \var{(X2,Y2)}, in the current line style and color. The
- current position is put to \var{(X2,Y2)}
- \Errors
- None.
- \SeeAlso
- \seep{LineRel},\seep{LineTo}
- \end{procedure}
- \begin{procedure}{LineRel}
- \Declaration
- Procedure LineRel (DX,DY : Integer);
- \Description
- \var{LineRel} draws a line starting from
- the current pointer position to the point\var{(DX,DY}, \textbf{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.
- \SeeAlso
- \seep{Line}, \seep{LineTo}
- \end{procedure}
- \begin{procedure}{LineTo}
- \Declaration
- Procedure LineTo (DX,DY : Integer);
- \Description
- \var{LineTo} draws a line starting from
- the current pointer position to the point\var{(DX,DY}, \textbf{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.
- \SeeAlso
- \seep{LineRel},\seep{Line}
- \end{procedure}
- \begin{procedure}{MoveRel}
- \Declaration
- Procedure MoveRel (DX,DY : Integer;
- \Description
- \var{MoveRel} moves the pointer to the
- point \var{(DX,DY)}, relative to the current pointer
- position
- \Errors
- None.
- \SeeAlso
- \seep{MoveTo}
- \end{procedure}
- \begin{procedure}{MoveTo}
- \Declaration
- Procedure MoveTo (X,Y : Integer;
- \Description
- \var{MoveTo} moves the pointer to the
- point \var{(X,Y)}.
- \Errors
- None.
- \SeeAlso
- \seep{MoveRel}
- \end{procedure}
- \begin{procedure}{OutText}
- \Declaration
- Procedure OutText (Const TextString : String);
- \Description
- \var{OutText} puts \var{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.
- \SeeAlso
- \seep{OutTextXY}
- \end{procedure}
- \begin{procedure}{OutTextXY}
- \Declaration
- Procedure OutTextXY (X,Y : Integer; Const TextString : String);
- \Description
- \var{OutText} puts \var{TextString} on the screen, at position \var{(X,Y)},
- using the current font and text settings. The current position is
- moved to the end of the text.
- \Errors
- None.
- \SeeAlso
- \seep{OutText}
- \end{procedure}
- \begin{procedure}{PieSlice}
- \Declaration
- Procedure PieSlice (X,Y : Integer; \\ Start,Stop,Radius : Word);
- \Description
- \var{PieSlice}
- draws and fills a sector of a circle with center \var{(X,Y)} and radius
- \var{Radius}, starting at angle \var{Start} and ending at angle \var{Stop}.
- \Errors
- None.
- \SeeAlso
- \seep{Arc}, \seep{Circle}, \seep{Sector}
- \end{procedure}
- \begin{procedure}{PutImage}
- \Declaration
- Procedure PutImage (X1,Y1 : Integer; Var Bitmap; How : word) ;
- \Description
- \var{PutImage}
- Places the bitmap in \var{Bitmap} on the screen at \var{(X1,Y1)}. \var{How}
- determines how the bitmap will be placed on the screen. Possible values are :
- \begin{itemize}
- \item CopyPut
- \item XORPut
- \item ORPut
- \item AndPut
- \item NotPut
- \end{itemize}
- \Errors
- None
- \SeeAlso
- \seef{ImageSize},\seep{GetImage}
- \end{procedure}
- \begin{procedure}{PutPixel}
- \Declaration
- Procedure PutPixel (X,Y : Integer; Color : Word);
- \Description
- Puts a point at
- \var{(X,Y)} using color \var{Color}
- \Errors
- None.
- \SeeAlso
- \seef{GetPixel}
- \end{procedure}
- \begin{procedure}{Rectangle}
- \Declaration
- Procedure Rectangle (X1,Y1,X2,Y2 : Integer);
- \Description
- Draws a rectangle with
- corners at \var{(X1,Y1)} and \var{(X2,Y2)}, using the current color and
- style.
- \Errors
- None.
- \SeeAlso
- \seep{Bar}, \seep{Bar3D}
- \end{procedure}
- \begin{function}{RegisterBGIDriver}
- \Declaration
- Function RegisterBGIDriver (Driver : Pointer) : Integer;
- \Description
- Registers a user-defined BGI driver
- \Errors
- None.
- \SeeAlso
- \seef{InstallUserDriver},
- \seef{RegisterBGIFont}
- \end{function}
- \begin{function}{RegisterBGIFont}
- \Declaration
- Function RegisterBGIFont (Font : Pointer) : Integer;
- \Description
- Registers a user-defined BGI driver
- \Errors
- None.
- \SeeAlso
- \seef{InstallUserFont},
- \seef{RegisterBGIDriver}
- \end{function}
- \begin{procedure}{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
- \var{SetGraphMode(GetGraphMode)}
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}
- \end{procedure}
- \begin{procedure}{Sector}
- \Declaration
- Procedure Sector (X,Y : Integer; \\ Start,Stop,XRadius,YRadius : Word);
- \Description
- \var{Sector}
- draws and fills a sector of an ellipse with center \var{(X,Y)} and radii
- \var{XRadius} and \var{YRadius}, starting at angle \var{Start} and ending at angle \var{Stop}.
- \Errors
- None.
- \SeeAlso
- \seep{Arc}, \seep{Circle}, \seep{PieSlice}
- \end{procedure}
- \begin{procedure}{SetActivePage}
- \Declaration
- Procedure SetActivePage (Page : Word);
- \Description
- Sets \var{Page} as the active page
- for all graphical output.
- \Errors
- None.
- \SeeAlso
- \end{procedure}
- \begin{procedure}{SetAllPallette}
- \Declaration
- Procedure SetAllPallette (Var Palette);
- \Description
- Sets the current palette to
- \var{Palette}. \var{Palette} is an untyped variable, usually pointing to a
- record of type \var{PaletteType}
- \Errors
- None.
- \SeeAlso
- \seep{GetPalette}
- \end{procedure}
- \begin{procedure}{SetAspectRatio}
- \Declaration
- Procedure SetAspectRatio (Xasp,Yasp : Word);
- \Description
- Sets the aspect ratio of the
- current screen to \var{Xasp/Yasp}.
- \Errors
- None
- \SeeAlso
- \seep{InitGraph}, \seep{GetAspectRatio}
- \end{procedure}
- \begin{procedure}{SetBkColor}
- \Declaration
- Procedure SetBkColor (Color : Word);
- \Description
- Sets the background color to
- \var{Color}.
- \Errors
- None.
- \SeeAlso
- \seef{GetBkColor}, \seep{SetColor}
- \end{procedure}
- \begin{procedure}{SetColor}
- \Declaration
- Procedure SetColor (Color : Word);
- \Description
- Sets the foreground color to
- \var{Color}.
- \Errors
- None.
- \SeeAlso
- \seef{GetColor}, \seep{SetBkColor}
- \end{procedure}
- \begin{procedure}{SetFillPattern}
- \Declaration
- Procedure SetFillPattern (FillPattern : FillPatternType,\\ Color : Word);
- \Description
- \var{SetFillPattern} sets the current fill-pattern to \var{FillPattern}, and
- the filling color to \var{Color}
- The pattern is an 8x8 raster, corresponding to the 64 bits in
- \var{FillPattern}.
- \Errors
- None
- \SeeAlso
- \seep{GetFillPattern}, \seep{SetFillStyle}
- \end{procedure}
- \begin{procedure}{SetFillStyle}
- \Declaration
- Procedure SetFillStyle (Pattern,Color : word);
- \Description
- \var{SetFillStyle} sets the filling pattern and color to one of the
- predefined filling patterns. \var{Pattern} can be one of the following predefined
- constants :
- \begin{itemize}
- \item \var{EmptyFill } Uses backgroundcolor.
- \item \var{SolidFill } Uses filling color
- \item \var{LineFill } Fills with horizontal lines.
- \item \var{ltSlashFill} Fills with lines from left-under to top-right.
- \item \var{SlashFill } Idem as previous, thick lines.
- \item \var{BkSlashFill} Fills with thick lines from left-Top to bottom-right.
- \item \var{LtBkSlashFill} Idem as previous, normal lines.
- \item \var{HatchFill} Fills with a hatch-like pattern.
- \item \var{XHatchFill} Fills with a hatch pattern, rotated 45 degrees.
- \item \var{InterLeaveFill}
- \item \var{WideDotFill} Fills with dots, wide spacing.
- \item \var{CloseDotFill} Fills with dots, narrow spacing.
- \item \var{UserFill} Fills with a user-defined pattern.
- \end{itemize}
- \Errors
- None.
- \SeeAlso
- \seep{SetFillPattern}
- \end{procedure}
- \begin{procedure}{SetGraphBufSize}
- \Declaration
- Procedure SetGraphBufSize (BufSize : Word);
- \Description
- \var{SetGraphBufSize} is a dummy function which does not do
- anything; it is no longer needed.
- \Errors
- None.
- \SeeAlso
- \end{procedure}
- \begin{procedure}{SetGraphMode}
- \Declaration
- Procedure SetGraphMode (Mode : Integer);
- \Description
- \var{SetGraphMode} sets the graphical mode and clears the screen.
- \Errors
- None.
- \SeeAlso
- \seep{InitGraph}
- \end{procedure}
- \begin{procedure}{SetLineStyle}
- \Declaration
- Procedure SetLineStyle (LineStyle,Pattern,Width :
- Word);
- \Description
- \var{SetLineStyle}
- sets the drawing style for lines. You can specify a \var{LineStyle} which is
- one of the following pre-defined constants:
- \begin{itemize}
- \item \var{Solidln=0;} draws a solid line.
- \item \var{Dottedln=1;} Draws a dotted line.
- \item \var{Centerln=2;} draws a non-broken centered line.
- \item \var{Dashedln=3;} draws a dashed line.
- \item \var{UserBitln=4;} Draws a User-defined bit pattern.
- \end{itemize}
- If \var{UserBitln} is specified then \var{Pattern} contains the bit pattern.
- In all another cases, \var{Pattern} is ignored. The parameter \var{Width}
- indicates how thick the line should be. You can specify one of the following
- pre-defined constants:
- \begin{itemize}
- \item \var{NormWidth=1}
- \item \var{ThickWidth=3}
- \end{itemize}
- \Errors
- None.
- \SeeAlso
- \seep{GetLineSettings}
- \end{procedure}
- \begin{procedure}{SetPalette}
- \Declaration
- Procedure SetPalette (ColorNr : Word; NewColor : ShortInt);
- \Description
- \var{SetPalette} changes the \var{ColorNr}-th entry in the palette to
- \var{NewColor}
- \Errors
- None.
- \SeeAlso
- \seep{SetAllPallette},\seep{SetRGBPalette}
- \end{procedure}
- \begin{procedure}{SetRGBPalette}
- \Declaration
- Procedure SetRGBPalette (ColorNr,Red,Green,Blue : Integer);
- \Description
- \var{SetRGBPalette} sets the \var{ColorNr}-th entry in the palette to the
- color with RGB-values \var{Red, Green Blue}.
- \Errors
- None.
- \SeeAlso
- \seep{SetAllPallette},
- \seep{SetPalette}
- \end{procedure}
- \begin{procedure}{SetTextJustify}
- \Declaration
- Procedure SetTextJustify (Horizontal,Vertical : Word);
- \Description
- \var{SetTextJustify} controls the placement of new text, relative to the
- (graphical) cursor position. \var{Horizontal} controls horizontal placement, and can be
- one of the following pre-defined constants:
- \begin{itemize}
- \item \var{LeftText=0;} Text is set left of the pointer.
- \item \var{CenterText=1;} Text is set centered horizontally on the pointer.
- \item \var{RightText=2;} Text is set to the right of the pointer.
- \end{itemize}
- \var{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 :
- \begin{itemize}
- \item \var{BottomText=0;} Text is placed under the pointer.
- \item \var{CenterText=1;} Text is placed centered vertically on the pointer.
- \item \var{TopText=2;}Text is placed above the pointer.
- \end{itemize}
- \Errors
- None.
- \SeeAlso
- \seep{OutText}, \seep{OutTextXY}
- \end{procedure}
- \begin{procedure}{SetTextStyle}
- \Declaration
- Procedure SetTextStyle (Font,Direction,Magnitude : Word);
- \Description
- \var{SetTextStyle} controls the style of text to be put on the screen.
- pre-defined constants for \var{Font} are:
- \begin{itemize}
- \item \var{DefaultFont=0;}
- \item \var{TriplexFont=2;}
- \item \var{SmallFont=2;}
- \item \var{SansSerifFont=3;}
- \item \var{GothicFont=4;}
- \end{itemize}
- Pre-defined constants for \var{Direction} are :
- \begin{itemize}
- \item \var{HorizDir=0;}
- \item \var{VertDir=1;}
- \end{itemize}
- \Errors
- None.
- \SeeAlso
- \seep{GetTextSettings}
- \end{procedure}
- \begin{procedure}{SetUserCharSize}
- \Declaration
- Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
- \Description
- Sets the width and height of vector-fonts. The horizontal size is given
- by \var{Xasp1/Xasp2}, and the vertical size by \var{Yasp1/Yasp2}.
- \Errors
- None.
- \SeeAlso
- \seep{SetTextStyle}
- \end{procedure}
- \begin{procedure}{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 \var{(X1,Y1)} and the bottom-right corner \var{(X2,Y2)}.
- If \var{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.
- \SeeAlso
- \seep{GetViewSettings}
- \end{procedure}
- \begin{procedure}{SetVisualPage}
- \Declaration
- Procedure SetVisualPage (Page : Word);
- \Description
- \var{SetVisualPage} sets the video page to page number \var{Page}.
- \Errors
- None
- \SeeAlso
- \seep{SetActivePage}
- \end{procedure}
- \begin{procedure}{SetWriteMode}
- \Declaration
- Procedure SetWriteMode (Mode : Integer);
- \Description
- \var{SetWriteMode} controls the drawing of lines on the screen. It controls
- the binary operation used when drawing lines on the screen. \var{Mode} can
- be one of the following pre-defined constants:
- \begin{itemize}
- \item CopyPut=0;
- \item XORPut=1;
- \end{itemize}
- \Errors
- None.
- \SeeAlso
- \end{procedure}
- \begin{function}{TextHeight}
- \Declaration
- Function TextHeight (S : String) : Word;
- \Description
- \var{TextHeight} returns the height (in pixels) of the string \var{S} in
- the current font and text-size.
- \Errors
- None.
- \SeeAlso
- \seef{TextWidth}
- \end{function}
- \begin{function}{TextWidth}
- \Declaration
- Function TextWidth (S : String) : Word;
- \Description
- \var{TextHeight} returns the width (in pixels) of the string \var{S} in
- the current font and text-size.
- \Errors
- None.
- \SeeAlso
- \seef{TextHeight}
- \end{function}
- % Target specific issues.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \section{Target specific issues}
- In what follows we describe some things that are different on the various
- platforms:
- \subsection{\dos}
- \subsection{\windows}
- \subsection{\linux}
|