Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / rtl / inc / graph / graph.tex
blobfbd24b2d0678d87c433d41209bd364a523eb46b5
2 % $Id$
3 % This file is part of the FPC documentation.
4 % Copyright (C) 1997,1999-2000 by the Free Pascal Development team
6 % The FPC documentation is free text; you can redistribute it and/or
7 % modify it under the terms of the GNU Library General Public License as
8 % published by the Free Software Foundation; either version 2 of the
9 % License, or (at your option) any later version.
11 % The FPC Documentation is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 % Library General Public License for more details.
16 % You should have received a copy of the GNU Library General Public
17 % License along with the FPC documentation; see the file COPYING.LIB. If not,
18 % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 % Boston, MA 02111-1307, USA.
21 % Documentation for the 'Graph' unit of Free Pascal.
22 % Michael Van Canneyt, July 1997
23 % Carl Eric Codere, April 1999
24 \chapter{The GRAPH unit.}
25 This document describes the \textbf{GRAPH} unit for Free Pascal. This unit includes
26 more then 50 graphics routines, that range from low-level calls such as putpixel
27 to high level calls like Circle and Bar3D. Different fill styles and line
28 patterns are supported in most of the routines.
30 \section{Overview}
31 \label{se:Overview}
33 \subsection{Compatibility}
34 Since the graph unit included with \var{fpc} is a portable implementation of
35 the Turbo Pascal unit, there are some slight differences between the video
36 modes and features.
38 \subsubsection{Initialization}
40 Each graph unit implementation, will have a 320x200 resolution refered to
41 \textit{LowResolution}. If the hardware for the specific platform does
42 not support that resolution, then it will have to be emulated. Apart
43 from that requirement, all other resolutions will be dependant on the
44 target platform.
46 The correct way and portable way to initialize to graphics subsystem, is
47 to first query the hardware, and then from that, decide which mode you
48 wish to support. The routine which does this is called \textit{QueryAdapterInfo}.
49 This routine returns a linked list of modes availables, and their
50 mode number as well as driver numbers. It is to note that this list is
51 initialized only once during the lifetime of the application (that is,
52 even if CloseGraph is called, the list will still be valid). The memory
53 allocated for this list is automatically freed as part as the graph
54 unit's exit procedure.
56 You can always use Detect as a parameter to \textit{InitGraph}
57 which will initialize the graphics to the highest resolution possible.
59 The following constants are also defined for compatiblity with older
60 applications written with Turbo Pascal, they should no longer be used:
62 \begin{tabular}{|c|c|c|}
63 \hline
64 Driver Name & Constant Name & Column x Row & Colors \\ \hline
65 VGA & VGAHi & 640x480 & 16 \\
66 VGA & VGALo & 640x200 & 16 \\
67 VGA & VGAMed & 640x350 & 16 \\
68 VGA & VGA256 & 320x200 & 256 \\
69 \hline
70 \end{tabular}
72 \subsubsection{Other differences}
74 Some notable differences with the Turbo Pascal graph unit are noted
75 below:
77 \begin{itemize}
78 \item \textit{Rectangle} do not write
79 the end points twice, which permits the XORPut write mode to be used
80 effectively for erasing these forms on the screen.
81 \item \textit{RegisterBGIDriver} and \textit{InstallUserDriver} always
82 return errors, as they are not directly supported.
83 \item \textit{DrawPoly} XORPut write mode does not have the same behaviour
84 as the one in the Turbo Pascal graph unit.
85 \item XORPut write mode is not supported by \textit{Bar3d}.
86 \item Passing invalid parameters to \textit{SetTextStyle} will not
87 result in the same visual appearance. Make sure your input is valid.
88 \item All routines using sines/cosines (e.g: \textit{circle}), don't
89 exactly have the same radii, because the aspect ratio correction is
90 different.
91 \item PutImage supports clipping.
92 \item \textit{SetRGBPalette} use the LSB's of the RGB components to
93 set the color values of the palette. This makes the unit more portable.
94 \item \textit{PaletteType} is different then the Turbo Pascal version,
95 it uses RGB Values for the palettes.
96 \item \textit{SetAllPalette} is different then the Turbo Pascal version,
97 it uses the PaletteType as a parameter.
98 \item \textit{GetDefaultPalette} only returns only at most the 256 first
99 default entries of a palette, even if the mode supports more then
100 256 colors.
101 \end{itemize}
103 \subsection{Coordinate system}
104 The upper left of the graphics screen is located at position (0,0). The x
105 value, which represents the column, increments to the right. The y values,
106 or rows, increment downward. The maximum value which can be set for an x
107 value, for the graphics screen is given by the \textit{GetMaxX} routine.
108 The same is true for the y coordinate, except a call to \textit{GetMaxY}
109 is required.
111 \subsection{Current pointer}
112 Some graphics routines support the concept of the current pointer (CP). The
113 current pointer is similar in concept to a text cursor, except that it is
114 invisible.
116 When you write in text mode, the text cursor is automatically incremented
117 by the number of characters written. The same is true with the graphics
118 current pointer, which is instead incremented on a pixel basis.
120 For example, the following:
121 \begin{verbatim}
123 MoveTo(0,0);
124 LineTo(100,100);
126 \end{verbatim}
128 will leave the current pointer to the (100,100) coordinate pair. The
129 pixels might not be drawn depending on your clipping settings, but the
130 CP is never clipped to clipping boundaries.
132 The following routines set the CP to the new position:
134 \begin{itemize}
135 \item \textit{ClearDevice}
136 \item \textit{ClearViewPort}
137 \item \textit{GraphDefaults}
138 \item \textit{InitGraph}
139 \item \textit{LineRel}
140 \item \textit{LineTo}
141 \item \textit{MoveRel}
142 \item \textit{MoveTo}
143 \item \textit{OutText}
144 \item \textit{SetGraphMode}
145 \item \textit{SetViewPort}
146 \end{itemize}
148 \subsection{Error handling}
150 There is only basic error checking in the graph unit. To get the value of
151 the last error returned by a graphics driver call, call the
152 \textit{GraphResult} routine. The following routines can set error codes,
153 others don't :
155 \begin{itemize}
156 \item \textit{Bar} --- ok
157 \item \textit{Bar3D} --- ok
158 \item \textit{ClearViewPort}
159 \item \textit{CloseGraph} --- ok
160 \item \textit{DetectGraph} --- ok
161 \item \textit{DrawPoly} --- ok
162 \item \textit{FillPoly} --- ok
163 \item \textit{FloodFill} --- ok
164 \item \textit{GetModeName} --- ok
165 \item \textit{GetRGBPalette} --- ok
166 \item \textit{InitGraph} --- ok
167 \item \textit{InstallUserDriver} --- ok
168 \item \textit{InstallUserFont} --- ok
169 \item \textit{PieSlice}
170 \item \textit{RegisterBGIDriver} --- ok
171 \item \textit{RegisterBGIFont} --- ok
172 \item \textit{SetAllPalette} --- ok
173 \item \textit{SetFillPattern} --- ok
174 \item \textit{SetFillStyle} --- ok
175 \item \textit{SetGraphBufSize}
176 \item \textit{SetGraphMode}
177 \item \textit{SetLineStyle} --- ok
178 \item \textit{SetPalette} --- ok
179 \item \textit{SetRGBPalette} --- ok
180 \item \textit{SetTextJustify} --- ok
181 \item \textit{SetTextStyle} --- ok
182 \item \textit{SetViewPort} --- ok
183 \end{itemize}
185 \textit{GraphResult} is reset to zero after it has been called. Therefore
186 the user should store the value returned by this function into a temporary
187 variable and then use it.
189 \subsection{Write modes}
191 Write modes permits combining colors with already existing on-screen colors,
192 \textit{PutImage} supports several write modes, while most other routines
193 support only CopyPut/NormalPut and XORPut modes.
195 The following routines support XORPut write modes (all routines support
196 CopyPut modes):
198 \begin{itemize}
199 \item \textit{FillEllipse}
200 \item \textit{FillPoly}
201 \item \textit{Arc} with ThickWidth line styles only
202 \item \textit{Circle} with ThickWidth line styles only
203 \item \textit{Line}
204 \item \textit{LineRel}
205 \item \textit{LineTo}
206 \item \textit{Rectangle}
207 \item \textit{DrawPoly}
208 \end{itemize}
210 \subsection{Text}
211 An internal bitmap font is included with this implementation of the graph
212 unit. It also possible to load and use standard Borland CHR external
213 vectorized font files. A bitmapped font is defined in this case by
214 a matrix of 8x8 pixels. A vector font (also referred to as a stroked font)
215 is defined by a series of vectors that tell the graphics system how to draw
216 the font.
218 \subsection{Clipping and Viewports}
220 \textit{SetViewPort} makes all output commands operate in a rectangular
221 region of the screen. Most output routines are viewport relative until
222 the viewport is changed. If clipping is active, all graphics is output
223 is clipped to the current region.
225 There is always clipping to the screen boundaries, whatever the clipping
226 setting is.
228 \subsection{Internals}
230 To make porting to a new platform easier, some of the graph unit routines
231 have been designed using procedural variables. Some of the routines have
232 default hooks, while others must absolutely be implemented for every new
233 platform to make the graph unit work.
235 The following routines must be created for every new platform supported:
237 \begin{itemize}
238 \item \textit{CloseGraph}
239 \item \textit{DirectPutPixel}
240 \item \textit{PutPixel}
241 \item \textit{GetPixel}
242 \item \textit{InitMode}
243 \item \textit{SaveVideoState}
244 \item \textit{RestoreVideoState}
245 \item \textit{QueryAdapterInfo}
246 \item \textit{SetRGBPalette}
247 \item \textit{GetRGBPalette}
248 \end{itemize}
250 The following global variables must be setup for every new platform
251 supported:
252 InternalDriverName
254 \var{InternalDriverName}
256 This variable should be set to a string describing the platform driver
257 name. It is returned by the user function GetDriverName. Some examples
258 of driver names are 'DosGX', 'DirectX', 'QuickDrw','CyberGFX', 'Dive'.
263 \var{CloseGraph}
265 The CloseGraph routine is called directly by the user and must
266 do the necessary cleanup by freeing up all platform specific
267 memory allocations, and by calling RestoreVideoState.
269 \var{DirectPutPixel}
271 This routine is one of the most important callback routines with
272 PutPixel, it is called by most of the routines in the graph unit. It
273 is about the same as PutPixel except that the coordinates passed to
274 it are already in global (screen) coordinates, and that clipping has
275 already been performed. Note that the current WriteMode has to be taken
276 into account in this procedure.
278 \var{InitMode}
280 This callback routine is called by SetGraphMode to actualliy change to
281 the correct video mode. (SetGraphMode is called by InitGraph).
283 \var{SaveVideoState}
285 This routine is called by InitGraph before changing to the graphics video
286 mode, it should save the old video mode, save any internal video state
287 such as the palette entries.
289 \var{RestoreVideoState}
291 This routine should be called by CloseGraph, it should restore the video
292 mode to the one saved in SaveVideoState, and restore all appropriate video
293 information, so that the video is in the same state as it was when
294 SaveVideoState was called.
296 \var{QueryAdapterInfo}
298 This routine might be called by the user BEFORE we are in graphics
299 mode. It is called by the initialization code of the graph unit. It
300 creates a linked list of video capabilities and procedural hooks for
301 all supported video modes on the platform. Look at the DOS version,
302 to see how it works. This linked list can be read by the user before a
303 call to InitGraph to determine which mode to use.
305 The linked list is composed of mode information, as well to pointers
306 to the callback routines cited above. Some additional optional hooks
307 are also possible for those who wish to optimize the speed of the unit.
310 -------------------------------------------------------------
311 \begin{function}{GetModeName}
312 \Declaration
313 Function GetModeName (ModeNumber : smallint) : String;
315 \Description
317 Returns a string with the name of the specified graphics mode. The
318 return values are in the form, XRes x YRes NAME. This function is
319 useful for building menus, display status, and so forth.
321 \Errors
322 If the specified \var{ModeNumber} is invalid, the function returns an
323 empty string and sets GraphResult to grInvalidMode.
324 \SeeAlso
325 \seef{GetDriverName}, \seep{GetModeRange}, \seep{GetMaxMode}
326 \end{function}
327 ------------------------
328 \begin{procedure}{SetAllPalette}
329 \Declaration
330 Procedure SetAllPalette(var Palette: PaletteType) ;
331 \Description
332 \var{Palette} is of type PaletteType. The first field in Palette
333 contains the length of the palette. The next \textit{n} fields of
334 type \var{RGBRec} contains the Red-Green-Blue components to replace
335 that specific color with. A value of -1 will not change the previous
336 entry's value.
338 Note that valid colors depend on the current graphics mode.
340 If the number of palette entries to replace is greater then the
341 number of colors possible on the screen, \var{GraphResult} returns
342 a value of \var{grError} and no changes to the palette settings will
343 occur.
345 Changes to the palette take effect immediately on the screen. Each time
346 a palette color is changed, that color will be changed to the new color
347 value.
349 This routine returns \var{grError} if called in a direct color mode.
351 \Errors
352 None.
353 \SeeAlso
354 \seep{SetRGBPalette}, \seep{SetPalette}
355 \end{procedure}
356 ------------------------
358 ------------------------
359 \begin{procedure}{GetDefaultPalette}
360 \Declaration
361 Procedure GetDefaultPalette (Var Palette : PaletteType);
363 \Description
364 Returns a \var{PaletteType} record containing the default RGB color
365 values when the graphics mode is initialized. These values are based
366 on the IBM-PC VGA hardware adapter, but do not change from platform
367 to platform.
369 On other platforms the colors may not exactly match those
370 on the IBM-PC, but the match should be close enough for most uses. This
371 value is static and does never change.
373 Even if the modes can support more then 256 color entries, only the
374 256 first colors can be considered as having default values. Therefore,
375 at most this function will return 256 entries. To query all colors over
376 256 yourself, use \var{GetRGBPalette} for the entire palette range.
378 \Errors
379 None.
380 \SeeAlso
381 \seef{GetColor}, \seef{GetBkColor}, \seep{GetRGBPalette}
382 \end{procedure}
385 ------------------------
386 \begin{procedure}{GetPalette}
387 \Declaration
388 Procedure GetPalette (Var Palette : PaletteType);
390 \Description
391 \var{GetPalette} returns in \var{Palette} the current palette. The palette
392 is in LSB RGB format.
394 This routine returns \var{grError} if called in a direct color mode.
396 \Errors
397 None.
398 \SeeAlso
399 \seef{GetPaletteSize}, \seep{SetPalette}
400 \end{procedure}
401 ---------------------------
402 ---------------------------
403 \begin{function}{GetBkColor}
404 \Declaration
405 Function GetBkColor : Word;
407 \Description
408 \var{GetBkColor} returns the current background color. If in non direct color
409 mode, this returns the palette entry, otherwise it returns the direct
410 RGB value of the current drawing color.
411 \Errors
412 None.
413 \SeeAlso
414 \seef{GetColor},\seep{SetBkColor}
415 \end{function}
416 ---------------------------
417 \begin{function}{GetColor}
418 \Declaration
419 Function GetColor : Word;
421 \Description
422 \var{GetColor} returns the current drawing color. If in non direct color
423 mode, this returns the palette entry, otherwise it returns the direct
424 RGB value of the current drawing color.
425 \Errors
426 None.
427 \SeeAlso
428 \seef{GetColor},\seep{SetBkColor}
429 \end{function}
430 ---------------------------
431 \begin{procedure}{GetRGBPalette}
432 \Declaration
433 Procedure GetRGBPalette (ColorNum: intege; var Red,Green,Blue : smallint);
435 \Description
436 \var{GetRGBPalette} gets the \var{ColorNum}-th entry in the palette.
437 The Red , Green and Blue values returned arein LSB format.
438 If the palette entry could not be read for a reason,
439 the routine returns \var{grError}.
441 This routine returns \var{grError} if called in a direct color mode.
443 \Errors
444 None.
445 \SeeAlso
446 \seep{SetAllPallette},
447 \seep{SetPalette}
448 \seep{SetRGBPalette}
449 \end{procedure}
451 ----------------------------
452 ----------------------------
453 \begin{procedure}{SetDirectVideo}
454 \Declaration
455 Procedure SetDirectVideo (DirectAccess : boolean);
457 \Description
458 Determines how the video access should be done, if DirectAccess
459 is set to TRUE then access will be done directly to video memory, if
460 it is supported, otherwise Operating systems calls will be done to
461 access the video memory.
463 The behaviour of this routine depends on the platform, and is required
464 for example to use the graph unit under older multitaskers such as
465 Desqview (DOS platform). Certain modes re simply not supported
466 via Operating system calls, while others are only supported by the
467 operating system. In those cases this routine is simply ignored.
469 Using operating system calls to plot pixels is much slower then using
470 the direct mode, but it provides more compatibility.
472 \textbf{Platform specific}
473 Windows NT, OS/2, Windows '9x, Windows 3.x, Linux DOSEMU support
474 all \textit{standard} video DOS modes, even in DirectVideo mode.
475 Others, like Desqview, Topview, DoubleDOS and MultiDOS might not.
476 In that case, \vaR{SetDirectVideo} should be called and set to FALSE.
478 VESA modes are not considered as standard DOS video modes,
479 and should simply not be used under such multitaskers/emulators.
481 Mode-X is not considered a standard DOS mode, but is supported in
482 most modern operating systems, since it uses only standard VGA
483 I/O ports and memory. (Exception: older multitaskers such as Desqview).
485 NOT IMPLEMENTED YET.
488 \Errors
489 None.
490 \SeeAlso
491 \seef{GetDirectVideo}
492 \end{procedure}
494 ----------------------------
495 \begin{function}{GetDirectVideo}
496 \Declaration
497 Function GetDirectVideo : boolean;
499 \Description
500 Returns the state of the of DirectAccess flag. If this value returns
501 TRUE, then in the case where it is possible, the video memory is directly
502 accessed to plot graphics points, otherwise operating system calls
503 are used.
506 \Errors
507 None.
508 \SeeAlso
509 \seep{SetDirectVideo}
510 \end{procedure}
513 ----------------------------
516 \section{Reference}
521 \section{Constants, Types and Variables}
522 \subsection{Types}
523 \begin{verbatim}
524 ArcCoordsType = record
525 X,Y,Xstart,Ystart,Xend,Yend : smallint;
526 end;
527 FillPatternType = Array [1..8] of Byte;
528 FillSettingsType = Record
529 Pattern,Color : Word
530 end;
531 LineSettingsType = Record
532 LineStyle,Pattern, Width : Word;
533 end;
537 PointType = Record
538 X,Y : smallint;
539 end;
540 TextSettingsType = Record
541 Font,Direction, CharSize, Horiz, Vert : Word
542 end;
543 ViewPortType = Record
544 X1,Y1,X2,Y2 : smallint;
545 Clip : Boolean
546 end;
547 \end{verbatim}
549 \begin{verbatim}
550 PaletteType = Record
551 Size : longint;
552 Colors : array[0..MaxColors] of RGBRec;
553 end;
554 \end{verbatim}
556 This record is used by \textit{SetAllPalette} , \textit{GetPalette} and
557 \textit{GetDefaultPalette}. \textit{Size} indicated the number of RGB
558 entries in this record, followed by the RGB records for each color. It
559 is to note, that contrary to Turbo Pascal, the RGB components are in
560 the LSB's of the RGB component records. This makes easier compatibility
561 across different hardware platforms.
564 \section{Functions and procedures}
567 \begin{procedure}{Arc}
568 \Declaration
569 Procedure Arc (X,Y : smallint; stAngle,Endangle, radius : Word);
571 \Description
572 \var{Arc} draws part of a circle with center at \var{(X,Y)}, radius
573 \var{radius}, starting from angle \var{stAngle}, stopping at angle \var{EndAngle}.
574 These angles are measured counterclockwise. Information about the last call
575 to \var{Arc} can be retrieved by \var{GetArcCoords}.
576 \Errors
577 None.
578 \SeeAlso
579 \seep{Circle},\seep{Ellipse}
580 \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
581 \end{procedure}
583 \begin{procedure}{Bar}
584 \Declaration
585 Procedure Bar (X1,Y1,X2,Y2 : smallint);
587 \Description
588 Draws a rectangle with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
589 and fills it with the current color and fill-style.
590 \Errors
591 None.
592 \SeeAlso
593 \seep{Bar3D},
594 \seep{Rectangle}
595 \end{procedure}
597 \begin{procedure}{Bar3D}
598 \Declaration
599 Procedure Bar3D (X1,Y1,X2,Y2 : smallint; depth : Word; Top : Boolean);
601 \Description
602 Draws a 3-dimensional Bar with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
603 and fills it with the current color and fill-style.
604 \var{Depth} specifies the number of pixels used to show the depth of the
605 bar.
606 If \var{Top} is true; then a 3-dimensional top is drawn.
607 \Errors
608 None.
609 \SeeAlso
610 \seep{Bar}, \seep{Rectangle}
611 \end{procedure}
613 \begin{procedure}{Circle}
614 \Declaration
615 Procedure Circle (X,Y : smallint; Radius : Word);
617 \Description
618 \var{Circle} draws part of a circle with center at \var{(X,Y)}, radius
619 \var{radius} in the current color. Each graphics driver contains an
620 aspect ratio used by \var{Circle}, \var{Arc} and \var{PieSlice}.
621 \Errors
622 None.
623 \SeeAlso
624 \seep{Ellipse},\seep{Arc}
625 \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
626 \end{procedure}
628 \begin{procedure}{ClearDevice}
629 \Declaration
630 Procedure ClearDevice ;
632 \Description
633 Clears the graphical screen (with the current
634 background color), and sets the pointer at \var{(0,0)}
635 \Errors
636 None.
637 \SeeAlso
638 \seep{ClearViewPort}, \seep{SetBkColor}
639 \end{procedure}
641 \begin{procedure}{ClearViewPort}
642 \Declaration
643 Procedure ClearViewPort ;
645 \Description
646 Clears the current viewport. The current background color is used as filling
647 color. The pointer is set at \var{(0,0)}
648 \Errors
649 None.
650 \SeeAlso
651 \seep{ClearDevice},\seep{SetViewPort}, \seep{SetBkColor}
652 \end{procedure}
654 \begin{procedure}{CloseGraph}
655 \Declaration
656 Procedure CloseGraph ;
658 \Description
659 Closes the graphical system, restores the
660 screen mode which was active before the graphical mode was
661 activated and frees up any memory allocated in InitGraph.
662 \Errors
663 None.
664 \SeeAlso
665 \seep{InitGraph}
666 \end{procedure}
668 \begin{procedure}{DetectGraph}
669 \Declaration
670 Procedure DetectGraph (Var Driver, Modus : smallint);
672 \Description
673 Checks the hardware in the PC and determines the driver and screen-modus to
674 be used. These are returned in \var{Driver} and \var{Modus}, and can be fed
675 to \var{InitGraph}.
676 See the \var{InitGraph} for a list of drivers and modi.
677 \Errors
678 None.
679 \SeeAlso
680 \seep{InitGraph}
681 \end{procedure}
684 \begin{procedure}{DrawPoly}
685 \Declaration
686 Procedure DrawPoly (NumPoints : Word; Var PolyPoints);
688 \Description
690 Draws a polygon with \var{NumPoints} corner points, using the
691 current color and linestyle. PolyPoints is an array of type \var{PointType}.
693 If there are less the two points in \var{PolyPoints}, this routine
694 returns \var{grError}.
696 \Errors
697 None.
698 \SeeAlso
699 \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
700 \end{procedure}
702 \begin{procedure}{Ellipse}
703 \Declaration
704 Procedure Ellipse (X,Y : smallint; StAngle,EndAngle,XRadius,YRadius : Word);
706 \Description
707 \var{Ellipse} draws part of an ellipse with center at \var{(X,Y)}.
708 \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
709 ellipse. \var{StAngle} and \var{EndAngle} are the starting and stopping angles of
710 the part of the ellipse. They are measured counterclockwise from the X-axis.
712 Information about the last call to \var{Ellipse} can be retrieved by
713 \var{GetArcCoords}.
715 \Errors
716 None.
717 \SeeAlso
718 \seep{Arc} \seep{Circle}, \seep{FillEllipse}
719 \end{procedure}
720 \begin{procedure}{FillEllipse}
721 \Declaration
722 Procedure FillEllipse (X,Y : smallint; Xradius,YRadius: Word);
724 \Description
725 \var{Ellipse} draws an ellipse with center at \var{(X,Y)}.
726 \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
727 ellipse. The ellipse is filled with the current color and fill style.
728 \Errors
729 None.
730 \SeeAlso
731 \seep{Arc} \seep{Circle},
732 \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
733 \end{procedure}
735 \begin{procedure}{FillPoly}
736 \Declaration
737 Procedure FillPoly (NumberPoints : Word; Var PolyPoints);
739 \Description
741 Draws a polygon with \var{NumPoints} corner points and fills it
742 using the current color and fill style. The outline of the polygon
743 is drawn in the current line style and color as set by \var{SetLineStyle}.
744 PolyPoints is an array of type \var{PointType}.
746 \Errors
747 None.
748 \SeeAlso
749 \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
750 \end{procedure}
751 \begin{procedure}{FloodFill}
752 \Declaration
753 Procedure FloodFill (X,Y : smallint; BorderColor : Word);
755 \Description
757 Fills the area containing the point \var{(X,Y)}, bounded by the color
758 \var{BorderColor}. The flooding is done using the current fill style
759 and fill color, as set by \var{SetFillStyle} or \var{SetFillPattern}.
761 This routine is here for compatibility only, \var{FillPoly} should be
762 used instead, since it is much faster.
764 \Errors
765 None
766 \SeeAlso
767 \seep{FillPoly},
768 \end{procedure}
770 \begin{procedure}{GetArcCoords}
771 \Declaration
772 Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
774 \Description
775 \var{GetArcCoords} returns the coordinates of the last \var{Arc} or
776 \var{Ellipse} call. The values are useful for connecting a line to
777 the end of an ellipse.
778 \Errors
779 None.
780 \SeeAlso
781 \seep{Arc}, \seep{Ellipse}
782 \end{procedure}
784 \begin{procedure}{GetAspectRatio}
785 \Declaration
786 Procedure GetAspectRatio (Var Xasp,Yasp : Word);
788 \Description
789 \var{GetAspectRatio} determines the effective resolution of the screen. The aspect ration can
790 the be calculated as \var{Xasp/Yasp}.
792 Each graphics driver uses this aspect ratio to make circles and any circular
793 shape look round on the screen.
794 \Errors
795 None.
796 \SeeAlso
797 \seep{InitGraph},\seep{SetAspectRatio}
798 \end{procedure}
801 \begin{function}{GetDriverName}
802 \Declaration
803 Function GetDriverName : String;
805 \Description
806 \var{GetDriverName} returns a string containing the name of the
807 current driver. This name can be anything under FPC, but it is
808 usually indicative of the API and/or platform used to perform the
809 graphics call.
810 \Errors
811 None.
812 \SeeAlso
813 \seef{GetModeName}, \seep{InitGraph}
814 \end{function}
816 \begin{procedure}{GetFillPattern}
817 \Declaration
818 Procedure GetFillPattern (Var FillPattern : FillPatternType);
820 \Description
821 \var{GetFillPattern} returns an array with the current fill pattern in \var{FillPattern}.
822 If no user call has been made to \var{SetFillPattern}, the pattern will be
823 filled with \var{$FF}.
825 It is to note that the user fill pattern is reset to \var{$FF} each time
826 \var{GraphDefaults} is called.
828 \Errors
829 None
830 \SeeAlso
831 \seep{SetFillPattern}, \seep{GraphDefaults}
832 \end{procedure}
834 \begin{procedure}{GetFillSettings}
835 \Declaration
836 Procedure GetFillSettings (Var FillInfo : FillSettingsType);
838 \Description
839 \var{GetFillSettings} returns the current fill-settings in
840 \var{FillInfo}
841 \Errors
842 None.
843 \SeeAlso
844 \seep{SetFillPattern}
845 \end{procedure}
847 \begin{function}{GetGraphMode}
848 \Declaration
849 Function GetGraphMode : smallint;
851 \Description
852 \var{GetGraphMode} returns the current graphical mode. This value is
853 entirely dependant on the hardware platform. To look up what this
854 mode number represents from a capabilities standpoint, you should
855 call either \var{QueryAdapterInfo} or \var{GetModeName} with the
856 value returned by this function.
857 \Errors
858 None.
859 \SeeAlso
860 \seep{InitGraph}, \seep{QueryAdapterInfo}, \seep{GetModeName}
861 \end{function}
863 \begin{procedure}{GetImage}
864 \Declaration
865 Procedure GetImage (X1,Y1,X2,Y2 : smallint, Var Bitmap);
867 \Description
868 \var{GetImage}
869 Places a copy of the screen area \var{(X1,Y1)} to \var{X2,Y2} in \var{BitMap}.
870 \var{Bitmap} is an untyped parameter that must be equal to 12 plus the size
871 of the screen area to save. The first two longints of \var{Bitmap} store
872 the width and height of the region. The third longint is reserved and should
873 not be modified.
875 To make access to the screen faster, it is recommended that the starting
876 points and ending point coordinates be modulo 4 and that the width to
877 save be also modulo 4.
879 To get the size of the bitmap required to save the area, you should call
880 \var{ImageSize}.
882 \Errors
883 Bitmap must have enough room to contain the image.
884 \SeeAlso
885 \seef{ImageSize},
886 \seep{PutImage}
887 \end{procedure}
889 \begin{procedure}{GetLineSettings}
890 \Declaration
891 Procedure GetLineSettings (Var LineInfo : LineSettingsType);
893 \Description
894 \var{GetLineSettings} returns the current Line settings in
895 \var{LineInfo}
896 \Errors
897 None.
898 \SeeAlso
899 \seep{SetLineStyle}
900 \end{procedure}
901 \begin{function}{GetMaxColor}
902 \Declaration
903 Function GetMaxColor : Word;
905 \Description
906 \var{GetMaxColor} returns the maximum color-number which can
907 be set with \var{SetColor}. This value is zero based, so a screen
908 which supports 16 colors, would return 15.
910 \Errors
911 None.
912 \SeeAlso
913 \seep{SetColor},
914 \seef{GetPaletteSize}
915 \end{function}
916 \begin{function}{GetMaxMode}
917 \Declaration
918 Function GetMaxMode : Word;
920 \Description
921 \var{GetMaxMode} returns the highest mode for the current driver. Normally
922 the higher the mode number, the resolution it will be, but this might not
923 always be the case.
924 \Errors
925 None.
926 \SeeAlso
927 \seep{InitGraph}
928 \end{function}
930 \begin{function}{GetMaxX}
931 \Declaration
932 Function GetMaxX : Word;
934 \Description
935 \var{GetMaxX} returns the maximum horizontal screen
936 length (zero based from 0..\var{MaxX}).
937 \Errors
938 None.
939 \SeeAlso
940 \seef{GetMaxY}
941 \end{function}
942 \begin{function}{GetMaxY}
943 \Declaration
944 Function GetMaxY : Word;
946 \Description
947 \var{GetMaxY} returns the maximum number of screen
948 lines. (zero based from 0..\var{MaxY}).
949 \Errors
950 None.
951 \SeeAlso
952 \seef{GetMaxY}
953 \end{function}
955 \begin{procedure}{GetModeRange}
956 \Declaration
957 Procedure GetModeRange (GraphDriver : smallint; var LoMode, HiMode: smallint);
959 \Description
960 \var{GetModeRange} returns the Lowest and Highest mode of the currently
961 installed driver. If the value of \var{GraphDriver} is invalid, \var{LoMode}
962 and var{HiMode} are set to -1.
963 \Errors
964 None.
965 \SeeAlso
966 \seep{InitGraph}, \seep{GetModeName}
967 \end{procedure}
968 \begin{function}{GetPaletteSize}
969 \Declaration
970 Function GetPaletteSize : Word;
972 \Description
973 \var{GetPaletteSize} returns the maximum number of entries which
974 can be set in the current palette. In direct color mode, this simply
975 returns the maximum possible of colors on screen.
977 Usually this has the value \var{GetMaxColor} + 1.
979 \Errors
980 None.
981 \SeeAlso
982 \seep{GetPalette},
983 \seep{SetPalette}
984 \seep{GetMaxColor}
985 \end{function}
986 \begin{function}{GetPixel}
987 \Declaration
988 Function GetPixel (X,Y : smallint) : Word;
990 \Description
991 \var{GetPixel} returns the color
992 of the point at \var{(X,Y)} The coordinates, as all coordinates
993 are viewport relative.
995 In direct color mode, the value returned is the direct RGB components of
996 the color. In palette based modes, this indicates the palette entry number.
998 \Errors
999 None.
1000 \SeeAlso
1002 \end{function}
1003 \begin{procedure}{GetTextSettings}
1004 \Declaration
1005 Procedure GetTextSettings (Var TextInfo : TextSettingsType);
1007 \Description
1008 \var{GetTextSettings} returns the current text style settings : The font,
1009 direction, size and placement as set with \var{SetTextStyle} and
1010 \var{SetTextJustify}.
1011 \Errors
1012 None.
1013 \SeeAlso
1014 \seep{SetTextStyle}, \seep{SetTextJustify}
1016 \end{procedure}
1017 \begin{procedure}{GetViewSettings}
1018 \Declaration
1019 Procedure GetViewSettings (Var ViewPort : ViewPortType);
1021 \Description
1022 \var{GetViewSettings} returns the current view-port and clipping settings in
1023 \var{ViewPort}.
1024 \Errors
1025 None.
1026 \SeeAlso
1027 \seep{SetViewPort}
1028 \end{procedure}
1030 \begin{function}{GetX}
1031 \Declaration
1032 Function GetX : smallint;
1034 \Description
1035 \var{GetX} returns the X-coordinate of the current pointer. This value is
1036 viewport relative.
1037 \Errors
1038 None.
1039 \SeeAlso
1040 \seef{GetY}
1041 \end{function}
1042 \begin{function}{GetY}
1043 \Declaration
1044 Function GetY : smallint;
1046 \Description
1047 \var{GetY} returns the Y-coordinate of the current pointer. This value is
1048 viewport relative.
1049 \Errors
1050 None.
1051 \SeeAlso
1052 \seef{GetX}
1053 \end{function}
1054 \begin{procedure}{GraphDefaults}
1055 \Declaration
1056 Procedure GraphDefaults ;
1058 \Description
1059 \var{GraphDefaults} homes the current pointer, and resets the graphics
1060 system to the default values for:
1062 \begin{itemize}
1063 \item Active Line style is reset to normal width and filled line.
1064 \item The current fill color is set to the maximum palette color.
1065 \item The current fill style is set to \var{solidfill}.
1066 \item The user fill pattern is reset to \var{$FF}.
1067 \item The current drawing color is set to white.
1068 \item The current background color is reset to black.
1069 \item The viewport is reset to (0,0,\var{GetMaxX},\var{GetMaxY}).
1070 \item Clipping is enabled.
1071 \item The active write mode is set to normalput.
1072 \item Text settings are reset to : default font, \var{HorizDir},
1073 \var{LeftText} and \var{TopText}.
1074 \end{itemize}
1076 This routine is called by \var{SetGraphMode}.
1078 \Errors
1079 None.
1080 \SeeAlso
1081 \seep{SetViewPort}, \seep{SetFillStyle}, \seep{SetColor},
1082 \seep{SetBkColor}, \seep{SetLineStyle}, \seep{SetGraphMode}
1083 \end{procedure}
1085 \begin{function}{GraphErrorMsg}
1086 \Declaration
1087 Function GraphErrorMsg (ErrorCode : smallint) : String;
1089 \Description
1090 \var{GraphErrorMsg}
1091 returns a string describing the error \var{Errorcode}. This string can be
1092 used to let the user know what went wrong.
1093 \Errors
1094 None.
1095 \SeeAlso
1096 \seef{GraphResult}
1097 \end{function}
1098 \begin{function}{GraphResult}
1099 \Declaration
1100 Function GraphResult : smallint;
1102 \Description
1103 \var{GraphResult} returns an error-code for
1104 the last graphical operation. If the returned value is zero, all went well.
1105 A value different from zero means an error has occurred.
1107 Note that \var{GraphResult} is reset to zero after it has been called.
1108 Therefore the value should be saved into a temporary location if you wish
1109 to use it later.
1111 To see which routine might return errors, see the introduction section at
1112 the start of this reference.
1114 \Errors
1115 None.
1116 \SeeAlso
1117 \seef{GraphErrorMsg}
1118 \end{function}
1120 \begin{function}{ImageSize}
1121 \Declaration
1122 Function ImageSize (X1,Y1,X2,Y2 : smallint) : longint;
1124 \Description
1125 \var{ImageSize} returns the number of bytes needed to store the image
1126 by \var{GetImage} in the rectangle defined by \var{(X1,Y1)} and \var{(X2,Y2)}.
1127 The image size includes space for several words. The first three longints
1128 are reserved for use by \var{GetImage}, the first longint containing the
1129 width of the region, the second containing the height, and the third being
1130 reserved,the following words contains the bitmap itself.
1132 \textit{Compatibility:}
1133 The value returned by this function is a 32-bit value,
1134 and not a 16-bit value.
1136 \Errors
1137 None.
1138 \SeeAlso
1139 \seep{GetImage}
1140 \end{function}
1142 \begin{procedure}{InitGraph}
1143 \Declaration
1144 Procedure InitGraph (var GraphDriver,GraphModus : smallint;\\
1145 const PathToDriver : string);
1147 \Description
1149 \var{InitGraph} initializes the \var{graph} package.
1151 \var{GraphDriver} has two valid values: \var{GraphDriver=Detect} which
1152 performs an auto detect and initializes the highest possible mode with the most
1153 colors. This is dependant on the platform, and many of the non-standard
1154 modes amy not be detected automatically. \var{graphMode} is the mode you
1155 wish to use.
1157 \var{PathToDriver} is only needed, if you use the BGI fonts from
1158 Borland, which are fully supported under FPC.
1160 The exact rundown of \var{InitGraph} is as follows: First it calls
1161 \var{QueryAdapterInfo} to get the possible modes supported by the hardware.
1162 It then saves the video state, initalizes some global variables, then if
1163 auto-detection was requested, calls \var{GetModeRange} to get the highest
1164 possible mode available and supported, otherwise it searches if the requested
1165 mode is available in the database. Finally , in either case it calls
1166 \var{SetGraphMode}.
1168 If the requested driver or mode is invalid, this function returns either
1169 \var{grError} or \var{grInvalidMode}.
1171 Before calling this function, you should call QueryAdapterInfo, and
1172 go through the list of supported modes to determine which mode suites
1173 your needs. As stated in the introduction, each graph unit implementation
1174 should support a 320x200 color mode.
1176 \Errors
1177 None.
1178 \SeeAlso
1179 Introduction, (page \pageref{se:Introduction}),
1180 \seep{DetectGraph}, \seep{CloseGraph}, \seef{GraphResult},
1181 \seef{QueryAdapterInfo}
1182 \end{procedure}
1183 Example:
1184 \begin{verbatim}
1186 gd,gm : smallint;
1187 PathToDriver : string;
1188 begin
1189 gd:=detect; { highest possible resolution }
1190 gm:=0; { not needed, auto detection }
1191 PathToDriver:='C:\PP\BGI'; { path to BGI fonts,
1192 drivers aren't needed }
1193 InitGraph(gd,gm,PathToDriver);
1194 if GraphResult<>grok then
1195 halt; ..... { whatever you need }
1196 CloseGraph; { restores the old graphics mode }
1197 end.
1198 \end{verbatim}
1200 \begin{function}{InstallUserDriver}
1201 \Declaration
1202 Function InstallUserDriver (DriverPath : String; AutoDetectPtr: Pointer) : smallint;
1204 \Description
1205 This routine is not supported in FPC, it is here only for compatiblity and
1206 always returns \var{grError}.
1208 \Errors
1209 None.
1210 \SeeAlso
1211 \seep{InitGraph}, \seef{InstallUserFont}
1212 \end{function}
1213 \begin{function}{InstallUserFont}
1214 \Declaration
1215 Function InstallUserFont (FontPath : String) : smallint;
1217 \Description
1218 \var{InstallUserFont} adds the font in \var{FontPath} to the list of fonts
1219 available to the text system. If the maximum number of allocated fonts has
1220 been reached, this routine sets \var{GraphResult} to \var{grError}.
1221 \Errors
1222 None.
1223 \SeeAlso
1224 \seep{InitGraph}, \seef{InstallUserDriver}
1225 \end{function}
1226 \begin{procedure}{Line}
1227 \Declaration
1228 Procedure Line (X1,Y1,X2,Y2 : smallint);
1230 \Description
1231 \var{Line} draws a line starting from
1232 \var{(X1,Y1} to \var{(X2,Y2)}, in the current line style and color.
1233 The current pointer is not updated after this call.
1235 This is the base routine which is called by several other routines
1236 in this unit. This routine is somewhat faster then the other
1237 LineXXX routines contained herein.
1240 \Errors
1241 None.
1242 \SeeAlso
1243 \seep{LineRel},\seep{LineTo}
1244 \end{procedure}
1245 \begin{procedure}{LineRel}
1246 \Declaration
1247 Procedure LineRel (DX,DY : smallint);
1249 \Description
1250 \var{LineRel} draws a line starting from
1251 the current pointer position to the point\var{(DX,DY}, \textbf{relative} to the
1252 current position, in the current line style and color. The Current Position
1253 is set to the endpoint of the line.
1254 \Errors
1255 None.
1256 \SeeAlso
1257 \seep{Line}, \seep{LineTo}
1258 \end{procedure}
1259 \begin{procedure}{LineTo}
1260 \Declaration
1261 Procedure LineTo (DX,DY : smallint);
1263 \Description
1264 \var{LineTo} draws a line starting from
1265 the current pointer position to the point\var{(DX,DY}, \textbf{relative} to the
1266 current position, in the current line style and color. The Current position
1267 is set to the end of the line.
1268 \Errors
1269 None.
1270 \SeeAlso
1271 \seep{LineRel},\seep{Line}
1272 \end{procedure}
1273 \begin{procedure}{MoveRel}
1274 \Declaration
1275 Procedure MoveRel (DX,DY : smallint;
1277 \Description
1278 \var{MoveRel} moves the current pointer to the
1279 point \var{(DX,DY)}, relative to the current pointer
1280 position
1281 \Errors
1282 None.
1283 \SeeAlso
1284 \seep{MoveTo}
1285 \end{procedure}
1286 \begin{procedure}{MoveTo}
1287 \Declaration
1288 Procedure MoveTo (X,Y : smallint);
1290 \Description
1291 \var{MoveTo} moves the current pointer to the
1292 point \var{(X,Y)}.
1293 \Errors
1294 None.
1295 \SeeAlso
1296 \seep{MoveRel}
1297 \end{procedure}
1298 \begin{procedure}{OutText}
1299 \Declaration
1300 Procedure OutText (Const TextString : String);
1302 \Description
1303 \var{OutText} puts \var{TextString} on the screen, at the current pointer
1304 position, using the current font and text settings. The current pointer is
1305 updated only if the text justification is set to left and is horizontal.
1307 The text is truncated according to the current viewport settings if it
1308 cannot fit.
1310 In order to maintain compatibility when using several fonts, use \var{TextWidth}
1311 and \var{TextHeight} calls to determine the dimensions of the string.
1313 \Errors
1314 None.
1315 \SeeAlso
1316 \seep{OutTextXY}
1317 \end{procedure}
1318 \begin{procedure}{OutTextXY}
1319 \Declaration
1320 Procedure OutTextXY (X,Y : smallint; Const TextString : String);
1322 \Description
1323 \var{OutText} puts \var{TextString} on the screen, at position \var{(X,Y)},
1324 using the current font and text settings.
1326 Contrary to \var{OutText} , this routine does not update the current pointer.
1328 In order to maintain compatibility when using several fonts, use \var{TextWidth}
1329 and \var{TextHeight} calls to determine the dimensions of the string.
1331 \Errors
1332 None.
1333 \SeeAlso
1334 \seep{OutText}
1335 \end{procedure}
1336 \begin{procedure}{PieSlice}
1337 \Declaration
1338 Procedure PieSlice (X,Y,stangle,endAngle:smallint;Radius: Word);
1340 \Description
1341 \var{PieSlice}
1342 draws and fills a sector of a circle with center \var{(X,Y)} and radius
1343 \var{Radius}, starting at angle \var{StAngle} and ending at angle \var{EndAngle}
1344 using the current fill style and fill pattern. The pie slice is outlined
1345 with the current line style and current active color.
1346 \Errors
1347 None.
1348 \SeeAlso
1349 \seep{Arc}, \seep{Circle}, \seep{Sector}
1350 \end{procedure}
1351 \begin{procedure}{PutImage}
1352 \Declaration
1353 Procedure PutImage (X,Y: smallint; var Bitmap; BitBlt: Word);
1355 \Description
1356 \var{PutImage}
1357 Places the bitmap in \var{Bitmap} on the screen at upper left
1358 corner \var{(X, Y)}. \var{BitBlt} determines how the bitmap
1359 will be placed on the screen. Possible values are :
1360 \begin{itemize}
1361 \item CopyPut
1362 \item XORPut
1363 \item ORPut
1364 \item AndPut
1365 \item NotPut
1366 \end{itemize}
1368 \textit{Compatibility}
1370 Contrary to the Borland graph unit, putimage \textit{is} clipped to the
1371 viewport boundaries.
1373 \Errors
1374 None
1375 \SeeAlso
1376 \seef{ImageSize},\seep{GetImage}
1377 \end{procedure}
1378 \begin{procedure}{PutPixel}
1379 \Declaration
1380 Procedure PutPixel (X,Y : smallint; Color : Word);
1382 \Description
1383 Puts a point at
1384 \var{(X,Y)} using color \var{Color}. This routine is viewport
1385 relative.
1386 \Errors
1387 None.
1388 \SeeAlso
1389 \seef{GetPixel}
1390 \end{procedure}
1391 \begin{procedure}{Rectangle}
1392 \Declaration
1393 Procedure Rectangle (X1,Y1,X2,Y2 : smallint);
1395 \Description
1396 Draws a rectangle with
1397 corners at \var{(X1,Y1)} and \var{(X2,Y2)}, using the current color and
1398 the current line style.
1399 \Errors
1400 None.
1401 \SeeAlso
1402 \seep{Bar}, \seep{Bar3D}
1403 \end{procedure}
1404 \begin{function}{RegisterBGIDriver}
1405 \Declaration
1406 Function RegisterBGIDriver (Driver : Pointer) : smallint;
1408 \Description
1409 This routine is not supported in FPC. It is here for compatibility and it
1410 always returns \var{grError}.
1411 \Errors
1412 None.
1413 \SeeAlso
1414 \seef{InstallUserDriver},
1415 \seef{RegisterBGIFont}
1416 \end{function}
1417 \begin{function}{RegisterBGIFont}
1418 \Declaration
1419 Function RegisterBGIFont (Font : Pointer) : smallint;
1421 \Description
1422 This routine permits the user to add a font to the list of known fonts
1423 by the graph unit. \var{Font} is a pointer to image of the loaded font.
1425 The value returned is either a negative error number (\var{grInvalidFont}),
1426 or the font number you need to use when accessing it via \var{SetTextStyle}.
1428 This routine may be called before \var{InitGraph}.
1431 \textit{Compatibility}
1432 Watch out for the byte endian when using this routine. This might work
1433 on little endian machines, and not on big endian machines and vice-versa.
1436 \Errors
1437 None.
1438 \SeeAlso
1439 \seef{InstallUserFont},
1440 \seef{RegisterBGIDriver}
1441 \end{function}
1442 \begin{procedure}{RestoreCRTMode}
1443 \Declaration
1444 Procedure RestoreCRTMode ;
1446 \Description
1447 Restores the screen mode which was active before
1448 the graphical mode was started. Can be used to switch back and forth
1449 between text and graphics mode.
1450 \Errors
1451 None.
1452 \SeeAlso
1453 \seep{InitGraph}
1456 \end{procedure}
1458 Example:
1459 \begin{verbatim}
1460 uses Graph;
1463 Gd, Gm: smallint;
1464 Mode: smallint;
1465 begin
1466 Gd := Detect;
1467 InitGraph(Gd, Gm, ' ');
1468 if GraphResult <> grOk then
1469 Halt(1);
1470 OutText('<ENTER> to leave graphics:');
1471 Readln;
1472 RestoreCrtMode;
1473 Writeln('Now in text mode');
1474 Write('<ENTER> to enter graphics mode:');
1475 Readln;
1476 SetGraphMode(GetGraphMode);
1477 OutTextXY(0, 0, 'Back in graphics mode');
1478 OutTextXY(0, TextHeight('H'), '<ENTER> to quit:');
1479 Readln;
1480 CloseGraph;
1481 end.
1482 \end{verbatim}
1483 \begin{procedure}{Sector}
1484 \Declaration
1485 Procedure Sector (X,Y : smallint; StAngle,EndAngle,XRadius,YRadius : Word);
1487 \Description
1488 \var{Sector}
1489 draws and fills a sector of an ellipse with center \var{(X,Y)} and radii
1490 \var{XRadius} and \var{YRadius}, starting at angle \var{StAngle} and ending at angle
1491 \var{EndAngle}. The sector is outlined in the current color and filled with
1492 the pattern and color defined by \var{SetFillStyle} or \var{SetFillPattern}.
1493 \Errors
1494 None.
1495 \SeeAlso
1496 \seep{Arc}, \seep{Circle}, \seep{PieSlice}
1497 \end{procedure}
1498 \begin{procedure}{SetActivePage}
1499 \Declaration
1500 Procedure SetActivePage (Page : Word);
1502 \Description
1503 Sets \var{Page} as the active page
1504 for all graphical output. This means that all drawing will be done on this
1505 graphics, be it visible or not.
1507 The usual way to make fast animation, is to draw to a non visible active page
1508 and the simply call make that active page the visible page by calling
1509 \var{SetVisualPage}.
1511 \textit{Compatibility}:
1512 Not all systems and graphics mode support multiple graphics pages, to
1513 determine how many pages are available see \var{QueryAdapterInfo}.
1515 Multiple pages are currently not supported with DOS VESA modes.
1517 \Errors
1518 None.
1519 \SeeAlso
1520 \seep{SetVisualPage}, \seep{QueryAdapterInfo}
1522 \end{procedure}
1523 \begin{procedure}{SetAllPallette}
1524 \Declaration
1525 Procedure SetAllPallette (Var Palette);
1527 \Description
1528 Sets the current palette to
1529 \var{Palette}. \var{Palette} is an untyped variable, usually pointing to a
1530 record of type \var{PaletteType} which contains the Red, Green and Blue
1531 components of the RGB components to change for each color entry. If
1532 the Red, Green and Blue components are equal to -1 for a specific color
1533 entry, then that palette entry will not be changed. The size should
1534 contain the size of the palette to change (indexed at zero).
1536 \textit{Compatibility}:
1538 This call is not the same as in Turbo Pascal. RGB components should be
1539 set in LSB if each of the components has less then 16-bits resolution.
1541 This call is not supported in direct color modes.
1543 \Errors
1544 None.
1545 \SeeAlso
1546 \seep{GetPalette}
1547 \end{procedure}
1548 \begin{procedure}{SetAspectRatio}
1549 \Declaration
1550 Procedure SetAspectRatio (Xasp,Yasp : Word);
1552 \Description
1553 Sets the aspect ratio of the
1554 current screen to \var{Xasp/Yasp}. The value of the aspect ratio is used
1555 by certain routines herein to draw circles which will actually appear round
1556 depending on the screen mode.
1557 \Errors
1558 None
1559 \SeeAlso
1560 \seep{InitGraph}, \seep{GetAspectRatio}
1561 \end{procedure}
1562 \begin{procedure}{SetBkColor}
1563 \Declaration
1564 Procedure SetBkColor (Color : Word);
1566 \Description
1567 Sets the background color to
1568 \var{Color}.
1570 The behaviour of this routine depends if we are in a direct color
1571 mode or not. In direct color mode, this value represents the direct
1572 RGB values to plot to the screen. In non direct color mode, the value
1573 represents an index to the color palette entry on the hardware.
1575 \Errors
1576 None.
1577 \SeeAlso
1578 \seef{GetBkColor}, \seep{SetColor}
1579 \end{procedure}
1580 \begin{procedure}{SetColor}
1581 \Declaration
1582 Procedure SetColor (Color : Word);
1584 \Description
1585 Sets the foreground color to
1586 \var{Color}.
1588 The behaviour of this routine depends if we are in a direct color
1589 mode or not. In direct color mode, this value represents the direct
1590 RGB values to plot to the screen. In non direct color mode, the value
1591 represents an index to the color palette entry on the hardware.
1593 \Errors
1594 None.
1595 \SeeAlso
1596 \seef{GetColor}, \seep{SetBkColor}
1597 \end{procedure}
1598 \begin{procedure}{SetFillPattern}
1599 \Declaration
1600 Procedure SetFillPattern (Pattern : FillPatternType, Color : Word);
1602 \Description
1603 \var{SetFillPattern} sets the current fill-pattern to \var{Pattern}, and
1604 the filling color to \var{Color}. If invalid input is passed to
1605 \var{SetFillPattern}, \var{GraphResult} will return \var{grError}.
1607 The pattern is an 8x8 raster, corresponding to the 64 bits in
1608 \var{FillPattern}. Whenever a bit in a pattern byte is valued at 1,
1609 a pixel will be plotted. The pattern and color is used by \var{Bar},
1610 \var{FillPoly}, \var{FloodFill}, \var{bar3d}, \var{FillEllipse},
1611 \var{Sector}, and \var{PieSlice}.
1614 \Errors
1615 None
1616 \SeeAlso
1617 \seep{GetFillPattern}, \seep{SetFillStyle}
1618 \end{procedure}
1619 \begin{procedure}{SetFillStyle}
1620 \Declaration
1621 Procedure SetFillStyle (Pattern, Color : word);
1623 \Description
1624 \var{SetFillStyle} sets the filling pattern and color to one of the
1625 predefined filling patterns. \var{Pattern} can be one of the following predefined
1626 constants :
1627 \begin{itemize}
1628 \item \var{EmptyFill } Uses backgroundcolor.
1629 \item \var{SolidFill } Uses filling color
1630 \item \var{LineFill } Fills with horizontal lines.
1631 \item \var{ltSlashFill} Fills with lines from left-under to top-right.
1632 \item \var{SlashFill } Idem as previous, thick lines.
1633 \item \var{BkSlashFill} Fills with thick lines from left-Top to bottom-right.
1634 \item \var{LtBkSlashFill} Idem as previous, normal lines.
1635 \item \var{HatchFill} Fills with a hatch-like pattern.
1636 \item \var{XHatchFill} Fills with a hatch pattern, rotated 45 degrees.
1637 \item \var{InterLeaveFill}
1638 \item \var{WideDotFill} Fills with dots, wide spacing.
1639 \item \var{CloseDotFill} Fills with dots, narrow spacing.
1640 \item \var{UserFill} Fills with a user-defined pattern.
1641 \end{itemize}
1643 If invalid input is passed to \var{SetFillStyle},
1644 \var{GraphResult} will return \var{grError}.
1646 \Errors
1647 None.
1648 \SeeAlso
1649 \seep{SetFillPattern}
1650 \end{procedure}
1651 \begin{procedure}{SetGraphBufSize}
1652 \Declaration
1653 Procedure SetGraphBufSize (BufSize : Word);
1655 \Description
1656 This routine does nothing in FPC, and is here for compatibility.
1657 \Errors
1658 None.
1659 \SeeAlso
1661 \end{procedure}
1662 \begin{procedure}{SetGraphMode}
1663 \Declaration
1664 Procedure SetGraphMode (Mode : smallint);
1666 \Description
1667 \var{SetGraphMode} sets the
1668 graphical mode and clears the screen. \var{Mode} must be a valid mode,
1669 which can be queried by \var{QueryAdapterInfo}.
1671 If invalid input is passed to \var{SetGraphMode}, or if the mode cannot
1672 be set for a reason, \var{GraphResult} returns \var{grInvalidMode}.
1674 \var{SetGraphMode} resets all graphics variables to their default
1675 settings (such as if \var{GraphDefaults} was called, the active page
1676 is reset to page zero, the visual page is reset to page zero, and the viewport
1677 is set to the entire screen.
1679 \Errors
1680 None.
1681 \SeeAlso
1682 \seep{InitGraph}, \seep{QueryAdapterInfo}
1683 \end{procedure}
1684 \begin{procedure}{SetLineStyle}
1685 \Declaration
1686 Procedure SetLineStyle (LineStyle, Pattern, Thickness : Word);
1688 \Description
1689 \var{SetLineStyle}
1690 sets the drawing style for lines. You can specify a \var{LineStyle} which is
1691 one of the following pre-defined constants:
1692 \begin{itemize}
1693 \item \var{Solidln=0;} draws a solid line.
1694 \item \var{Dottedln=1;} Draws a dotted line.
1695 \item \var{Centerln=2;} draws a non-broken centered line.
1696 \item \var{Dashedln=3;} draws a dashed line.
1697 \item \var{UserBitln=4;} Draws a User-defined bit pattern.
1698 \end{itemize}
1699 If \var{UserBitln} is specified then \var{Pattern} contains the bit pattern to
1700 use for drawing the line. A bit of 1 specified a pixel which is on.
1702 In all another cases, \var{Pattern} is ignored. The parameter \var{Thickness}
1703 indicates how thick the line should be. You can specify one of the following
1704 pre-defined constants:
1705 \begin{itemize}
1706 \item \var{NormWidth=1}
1707 \item \var{ThickWidth=3}
1708 \end{itemize}
1710 If invalid input is passed to \var{SetLineStyle} , \var{GraphResult} will
1711 return \var{grError}.
1713 \Errors
1714 None.
1715 \SeeAlso
1716 \seep{GetLineSettings}
1717 \end{procedure}
1718 \begin{procedure}{SetPalette}
1719 \Declaration
1720 Procedure SetPalette (ColorNum : Word; Color : Shortint);
1722 \Description
1723 \var{SetPalette} changes the \var{ColorNum}-th entry in the palette to
1724 \var{Color}. For examples, \var{SetPalette(0, LightCyan)} makes the first
1725 color in the palette light cyan. \var{Color} only accepts certain default
1726 colors, as specified in the \var{Color constants} section. If invalid
1727 input is passed to \var{SetPalette}, \var{GraphResult} returns a value
1728 of \var{grError} and the palette remains intact.
1730 Changes made to the palette are immediately visible on the screen.
1732 This routine returns \var{grError} if called in a direct color mode.
1734 \Errors
1735 None.
1736 \SeeAlso
1737 \seep{SetAllPallette},\seep{SetRGBPalette}
1738 \end{procedure}
1739 \begin{procedure}{SetRGBPalette}
1740 \Declaration
1741 Procedure SetRGBPalette (ColorNum,Red,Green,Blue : smallint);
1743 \Description
1744 \var{SetRGBPalette} sets the \var{ColorNum}-th entry in the palette to the
1745 color with RGB values \var{Red, Green Blue}. The Red , Green and Blue values
1746 must be in LSB format. If the palette entry could not be changed for a
1747 reason, the routine returns \var{grError}.
1749 This routine returns \var{grError} if called in a direct color mode.
1751 \Errors
1752 None.
1753 \SeeAlso
1754 \seep{SetAllPallette},
1755 \seep{SetPalette}
1756 \seep{GetRGBPalette}
1757 \end{procedure}
1758 \begin{procedure}{SetTextJustify}
1759 \Declaration
1760 Procedure SetTextJustify (Horiz, Vert : Word);
1762 \Description
1763 \var{SetTextJustify} controls the placement of new text, relative to the
1764 (graphical) cursor position. \var{Horiz} controls horizontal placement, and can be
1765 one of the following pre-defined constants:
1766 \begin{itemize}
1767 \item \var{LeftText=0;} Text is set left of the current pointer.
1768 \item \var{CenterText=1;} Text is set centered horizontally on the current pointer.
1769 \item \var{RightText=2;} Text is set to the right of the current pointer.
1770 \end{itemize}
1771 \var{Vertical} controls the vertical placement of the text, relative to the
1772 (graphical) cursor position. Its value can be one of the following
1773 pre-defined constants :
1774 \begin{itemize}
1775 \item \var{BottomText=0;} Text is placed under the current pointer.
1776 \item \var{CenterText=1;} Text is placed centered vertically on the current pointer.
1777 \item \var{TopText=2;}Text is placed above the current pointer.
1778 \end{itemize}
1780 If invalid input is passed \var{SetTextJustify} , \var{GraphResult} returns
1781 \var{grError}.
1783 \Errors
1784 None.
1785 \SeeAlso
1786 \seep{OutText}, \seep{OutTextXY}
1787 \end{procedure}
1788 \begin{procedure}{SetTextStyle}
1789 \Declaration
1790 Procedure SetTextStyle (Font,Direction,Magnitude : Word);
1792 \Description
1793 \var{SetTextStyle} controls the style of text to be put on the screen.
1794 pre-defined constants for \var{Font} are:
1795 \begin{itemize}
1796 \item \var{DefaultFont=0;}
1797 \item \var{TriplexFont=2;}
1798 \item \var{SmallFont=2;}
1799 \item \var{SansSerifFont=3;}
1800 \item \var{GothicFont=4;}
1801 \end{itemize}
1804 Pre-defined constants for \var{Direction} are :
1805 \begin{itemize}
1806 \item \var{HorizDir=0;}
1807 \item \var{VertDir=1;}
1808 \end{itemize}
1810 Charsize indicated the magnification factor to use when drawing the fonts
1811 to the screen. When using the default internal font, this value can be
1812 any value equal or greater to one. In the case of stroked fonts, the
1813 value should always be equal or greater then 4.
1815 Stroked fonts are usually loaded from disk once onto the heap when a call
1816 is made to \var{SetTextStyle}.
1818 If there is an error when using this routine, \var{GraphResult} might return
1819 \var{grFontNotFound}, \var{grNoFontMem}, \var{grError}, \var{grIoError},
1820 \var{grInvalidFont}, or \var{grInvalidFontNum}.
1822 \Errors
1823 None.
1824 \SeeAlso
1825 \seep{GetTextSettings}
1826 \end{procedure}
1827 \begin{procedure}{SetUserCharSize}
1828 \Declaration
1829 Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
1831 \Description
1832 Sets the width and height of vector-fonts. The horizontal size is given
1833 by \var{Xasp1/Xasp2}, and the vertical size by \var{Yasp1/Yasp2}.
1834 \Errors
1835 None.
1836 \SeeAlso
1837 \seep{SetTextStyle}
1838 \end{procedure}
1839 \begin{procedure}{SetViewPort}
1840 \Declaration
1841 Procedure SetViewPort (X1,Y1,X2,Y2 : smallint; Clip : Boolean);
1843 \Description
1844 Sets the current graphical view-port (window) to the rectangle defined by
1845 the top-left corner \var{(X1,Y1)} and the bottom-right corner \var{(X2,Y2)}.
1846 If \var{Clip} is true, anything drawn outside the view-port (window) will be
1847 clipped (i.e. not drawn). Coordinates specified after this call are relative
1848 to the top-left corner of the view-port.
1849 \Errors
1850 None.
1851 \SeeAlso
1852 \seep{GetViewSettings}
1853 \end{procedure}
1854 \begin{procedure}{SetVisualPage}
1855 \Declaration
1856 Procedure SetVisualPage (Page : Word);
1858 \Description
1859 \var{SetVisualPage} sets the video page to page number \var{Page}.
1860 \Errors
1861 None
1862 \SeeAlso
1863 \seep{SetActivePage}
1864 \end{procedure}
1865 \begin{procedure}{SetWriteMode}
1866 \Declaration
1867 Procedure SetWriteMode (Mode : smallint);
1869 \Description
1870 \var{SetWriteMode} controls the drawing of lines on the screen. It controls
1871 the binary operation used when drawing lines on the screen. \var{Mode} can
1872 be one of the following pre-defined constants:
1873 \begin{itemize}
1874 \item CopyPut=0;
1875 \item XORPut=1;
1876 \end{itemize}
1878 If you specify another mode, it is mapped to one of the above acoording to
1879 the following table (for TP compatibility, may be changed in the future):
1880 \begin{itemize}
1881 \item Notput, Orput: CopyPut
1882 \item AndPut: XorPut
1883 \end{itemize}
1885 \Errors
1886 None.
1887 \SeeAlso
1889 \end{procedure}
1890 \begin{function}{TextHeight}
1891 \Declaration
1892 Function TextHeight (S : String) : Word;
1894 \Description
1895 \var{TextHeight} returns the height (in pixels) of the string \var{S} in
1896 the current font and text-size.
1898 \Errors
1899 None.
1900 \SeeAlso
1901 \seef{TextWidth}
1902 \end{function}
1903 \begin{function}{TextWidth}
1904 \Declaration
1905 Function TextWidth (S : String) : Word;
1907 \Description
1908 \var{TextHeight} returns the width (in pixels) of the string \var{S} in
1909 the current font and text-size.
1911 \Errors
1912 None.
1913 \SeeAlso
1914 \seef{TextHeight}
1915 \end{function}