graph.tex 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  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.
  10. %
  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.
  15. %
  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.
  20. %
  21. % Documentation for the 'Graph' unit of Free Pascal.
  22. % Michael Van Canneyt, July 1997
  23. \chapter{The GRAPH unit.}
  24. This document describes the \var{GRAPH} unit for Free Pascal, under \dos.
  25. The unit was first written for \dos by Florian kl\"ampfl.
  26. This chapter is divided in three sections.
  27. \begin{itemize}
  28. \item The first section gives an introduction to the graph unit.
  29. \item The second section lists the pre-defined constants, types and variables.
  30. \item The second section describes the functions which appear in the
  31. interface part of the \file{GRAPH} unit.
  32. \end{itemize}
  33. \section{Introduction}
  34. \label{se:Introduction}
  35. \subsection{Requirements}
  36. The unit Graph exports functions and procedures for graphical output.
  37. It requires at least a VESA compatible VGA-Card or a VGA-Card with software-driver
  38. (min. \textbf{512Kb} video memory).
  39. Before the graph unit can be used, be sure your graphics adapter supports
  40. the VESA-Standard. Otherwise in the most cases you can try to use a VESA-TSR
  41. to make your adapter VESA compatible (e.g. UNIVBE).
  42. \section{Constants, Types and Variables}
  43. \subsection{Types}
  44. \begin{verbatim}
  45. ArcCoordsType = record
  46. X,Y,Xstart,Ystart,Xend,Yend : Integer;
  47. end;
  48. FillPatternType = Array [1..8] of Byte;
  49. FillSettingsType = Record
  50. Pattern,Color : Word
  51. end;
  52. LineSettingsType = Record
  53. LineStyle,Pattern, Width : Word;
  54. end;
  55. PaletteType = Record
  56. Size : Byte;
  57. Colors : array[0..MAxColor] of shortint;
  58. end;
  59. PointType = Record
  60. X,Y : Integer;
  61. end;
  62. TextSettingsType = Record
  63. Font,Direction, CharSize, Horiz, Vert : Word
  64. end;
  65. ViewPortType = Record
  66. X1,Y1,X2,Y2 : Integer;
  67. Clip : Boolean
  68. end;
  69. \end{verbatim}
  70. \section{Functions and procedures}
  71. \begin{procedure}{Arc}
  72. \Declaration
  73. Procedure Arc (X,Y : Integer; start,stop, radius : Word);
  74. \Description
  75. \var{Arc} draws part of a circle with center at \var{(X,Y)}, radius
  76. \var{radius}, starting from angle \var{start}, stopping at angle \var{stop}.
  77. These angles are measured
  78. counterclockwise.
  79. \Errors
  80. None.
  81. \SeeAlso
  82. \seep{Circle},\seep{Ellipse}
  83. \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
  84. \end{procedure}
  85. \begin{procedure}{Bar}
  86. \Declaration
  87. Procedure Bar (X1,Y1,X2,Y2 : Integer);
  88. \Description
  89. Draws a rectangle with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
  90. and fills it with the current color and fill-style.
  91. \Errors
  92. None.
  93. \SeeAlso
  94. \seep{Bar3D},
  95. \seep{Rectangle}
  96. \end{procedure}
  97. \begin{procedure}{Bar3D}
  98. \Declaration
  99. Procedure Bar3D (X1,Y1,X2,Y2 : Integer; depth : Word; Top : Boolean);
  100. \Description
  101. Draws a 3-dimensional Bar with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
  102. and fills it with the current color and fill-style.
  103. \var{Depth} specifies the number of pixels used to show the depth of the
  104. bar.
  105. If \var{Top} is true; then a 3-dimensional top is drawn.
  106. \Errors
  107. None.
  108. \SeeAlso
  109. \seep{Bar}, \seep{Rectangle}
  110. \end{procedure}
  111. \begin{procedure}{Circle}
  112. \Declaration
  113. Procedure Circle (X,Y : Integer; Radius : Word);
  114. \Description
  115. \var{Circle} draws part of a circle with center at \var{(X,Y)}, radius
  116. \var{radius}.
  117. \Errors
  118. None.
  119. \SeeAlso
  120. \seep{Ellipse},\seep{Arc}
  121. \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
  122. \end{procedure}
  123. \begin{procedure}{ClearDevice}
  124. \Declaration
  125. Procedure ClearDevice ;
  126. \Description
  127. Clears the graphical screen (with the current
  128. background color), and sets the pointer at \var{(0,0)}
  129. \Errors
  130. None.
  131. \SeeAlso
  132. \seep{ClearViewPort}, \seep{SetBkColor}
  133. \end{procedure}
  134. \begin{procedure}{ClearViewPort}
  135. \Declaration
  136. Procedure ClearViewPort ;
  137. \Description
  138. Clears the current view-port. The current background color is used as filling
  139. color. The pointer is set at
  140. \var{(0,0)}
  141. \Errors
  142. None.
  143. \SeeAlso
  144. \seep{ClearDevice},\seep{SetViewPort}, \seep{SetBkColor}
  145. \end{procedure}
  146. \begin{procedure}{CloseGraph}
  147. \Declaration
  148. Procedure CloseGraph ;
  149. \Description
  150. Closes the graphical system, and restores the
  151. screen modus which was active before the graphical modus was
  152. activated.
  153. \Errors
  154. None.
  155. \SeeAlso
  156. \seep{InitGraph}
  157. \end{procedure}
  158. \begin{procedure}{DetectGraph}
  159. \Declaration
  160. Procedure DetectGraph (Var Driver, Modus : Integer);
  161. \Description
  162. Checks the hardware in the PC and determines the driver and screen-modus to
  163. be used. These are returned in \var{Driver} and \var{Modus}, and can be fed
  164. to \var{InitGraph}.
  165. See the \var{InitGraph} for a list of drivers and modi.
  166. \Errors
  167. None.
  168. \SeeAlso
  169. \seep{InitGraph}
  170. \end{procedure}
  171. \begin{procedure}{DrawPoly}
  172. \Declaration
  173. Procedure DrawPoly (NumberOfPoints : Word; Var PolyPoints;
  174. \Description
  175. Draws a polygone with \var{NumberOfPoints} corner points, using the
  176. current color and line-style. PolyPoints is an array of type \var{PointType}.
  177. \Errors
  178. None.
  179. \SeeAlso
  180. \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
  181. \end{procedure}
  182. \begin{procedure}{Ellipse}
  183. \Declaration
  184. Procedure Ellipse (X,Y : Integer; Start,Stop,XRadius,YRadius : Word);
  185. \Description
  186. \var{Ellipse} draws part of an ellipse with center at \var{(X,Y)}.
  187. \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
  188. ellipse. \var{Start} and \var{Stop} are the starting and stopping angles of
  189. the part of the ellipse.
  190. They are measured counterclockwise from the X-axis.
  191. \Errors
  192. None.
  193. \SeeAlso
  194. \seep{Arc} \seep{Circle}, \seep{FillEllipse}
  195. \end{procedure}
  196. \begin{procedure}{FillEllipse}
  197. \Declaration
  198. Procedure FillEllipse (X,Y : Integer; Xradius,YRadius: Word);
  199. \Description
  200. \var{Ellipse} draws an ellipse with center at \var{(X,Y)}.
  201. \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
  202. ellipse. The ellipse is filled with the current color and fill-style.
  203. \Errors
  204. None.
  205. \SeeAlso
  206. \seep{Arc} \seep{Circle},
  207. \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
  208. \end{procedure}
  209. \begin{procedure}{FillPoly}
  210. \Declaration
  211. Procedure FillPoly (NumberOfPoints : Word; Var PolyPoints);
  212. \Description
  213. Draws a polygone with \var{NumberOfPoints} corner points and fills it
  214. using the current color and line-style.
  215. PolyPoints is an array of type \var{PointType}.
  216. \Errors
  217. None.
  218. \SeeAlso
  219. \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
  220. \end{procedure}
  221. \begin{procedure}{FloodFill}
  222. \Declaration
  223. Procedure FloodFill (X,Y : Integer; BorderColor : Word);
  224. \Description
  225. Fills the area containing the point \var{(X,Y)}, bounded by the color
  226. \var{BorderColor}.
  227. \Errors
  228. None
  229. \SeeAlso
  230. \seep{SetColor}, \seep{SetBkColor}
  231. \end{procedure}
  232. \begin{procedure}{GetArcCoords}
  233. \Declaration
  234. Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
  235. \Description
  236. \var{GetArcCoords} returns the coordinates of the latest \var{Arc} or
  237. \var{Ellipse} call.
  238. \Errors
  239. None.
  240. \SeeAlso
  241. \seep{Arc}, \seep{Ellipse}
  242. \end{procedure}
  243. \begin{procedure}{GetAspectRatio}
  244. \Declaration
  245. Procedure GetAspectRatio (Var Xasp,Yasp : Word);
  246. \Description
  247. \var{GetAspectRatio} determines the effective resolution of the screen. The aspect ration can
  248. the be calculated as \var{Xasp/Yasp}.
  249. \Errors
  250. None.
  251. \SeeAlso
  252. \seep{InitGraph},\seep{SetAspectRatio}
  253. \end{procedure}
  254. \begin{function}{GetBkColor}
  255. \Declaration
  256. Function GetBkColor : Word;
  257. \Description
  258. \var{GetBkColor} returns the current background color (the palette
  259. entry).
  260. \Errors
  261. None.
  262. \SeeAlso
  263. \seef{GetColor},\seep{SetBkColor}
  264. \end{function}
  265. \begin{function}{GetColor}
  266. \Declaration
  267. Function GetColor : Word;
  268. \Description
  269. \var{GetColor} returns the current drawing color (the palette
  270. entry).
  271. \Errors
  272. None.
  273. \SeeAlso
  274. \seef{GetColor},\seep{SetBkColor}
  275. \end{function}
  276. \begin{procedure}{GetDefaultPalette}
  277. \Declaration
  278. Procedure GetDefaultPalette (Var Palette : PaletteType);
  279. \Description
  280. Returns the
  281. current palette in \var{Palette}.
  282. \Errors
  283. None.
  284. \SeeAlso
  285. \seef{GetColor}, \seef{GetBkColor}
  286. \end{procedure}
  287. \begin{function}{GetDriverName}
  288. \Declaration
  289. Function GetDriverName : String;
  290. \Description
  291. \var{GetDriverName} returns a string containing the name of the
  292. current driver.
  293. \Errors
  294. None.
  295. \SeeAlso
  296. \seef{GetModeName}, \seep{InitGraph}
  297. \end{function}
  298. \begin{procedure}{GetFillPattern}
  299. \Declaration
  300. Procedure GetFillPattern (Var FillPattern : FillPatternType);
  301. \Description
  302. \var{GetFillPattern} returns an array with the current fill-pattern in \var{FillPattern}
  303. \Errors
  304. None
  305. \SeeAlso
  306. \seep{SetFillPattern}
  307. \end{procedure}
  308. \begin{procedure}{GetFillSettings}
  309. \Declaration
  310. Procedure GetFillSettings (Var FillInfo : FillSettingsType);
  311. \Description
  312. \var{GetFillSettings} returns the current fill-settings in
  313. \var{FillInfo}
  314. \Errors
  315. None.
  316. \SeeAlso
  317. \seep{SetFillPattern}
  318. \end{procedure}
  319. \begin{function}{GetGraphMode}
  320. \Declaration
  321. Function GetGraphMode : Integer;
  322. \Description
  323. \var{GetGraphMode} returns the current graphical modus
  324. \Errors
  325. None.
  326. \SeeAlso
  327. \seep{InitGraph}
  328. \end{function}
  329. \begin{procedure}{GetImage}
  330. \Declaration
  331. Procedure GetImage (X1,Y1,X2,Y2 : Integer, Var Bitmap;
  332. \Description
  333. \var{GetImage}
  334. Places a copy of the screen area \var{(X1,Y1)} to \var{X2,Y2} in \var{BitMap}
  335. \Errors
  336. Bitmap must have enough room to contain the image.
  337. \SeeAlso
  338. \seef{ImageSize},
  339. \seep{PutImage}
  340. \end{procedure}
  341. \begin{procedure}{GetLineSettings}
  342. \Declaration
  343. Procedure GetLineSettings (Var LineInfo : LineSettingsType);
  344. \Description
  345. \var{GetLineSettings} returns the current Line settings in
  346. \var{LineInfo}
  347. \Errors
  348. None.
  349. \SeeAlso
  350. \seep{SetLineStyle}
  351. \end{procedure}
  352. \begin{function}{GetMaxColor}
  353. \Declaration
  354. Function GetMaxColor : Word;
  355. \Description
  356. \var{GetMaxColor} returns the maximum
  357. color-number which can be set with \var{SetColor}
  358. \Errors
  359. None.
  360. \SeeAlso
  361. \seep{SetColor},
  362. \seef{GetPaletteSize}
  363. \end{function}
  364. \begin{function}{GetMaxMode}
  365. \Declaration
  366. Function GetMaxMode : Word;
  367. \Description
  368. \var{GetMaxMode} returns the highest modus for
  369. the current driver.
  370. \Errors
  371. None.
  372. \SeeAlso
  373. \seep{InitGraph}
  374. \end{function}
  375. \begin{function}{GetMaxX}
  376. \Declaration
  377. Function GetMaxX : Word;
  378. \Description
  379. \var{GetMaxX} returns the maximum horizontal screen
  380. length
  381. \Errors
  382. None.
  383. \SeeAlso
  384. \seef{GetMaxY}
  385. \end{function}
  386. \begin{function}{GetMaxY}
  387. \Declaration
  388. Function GetMaxY : Word;
  389. \Description
  390. \var{GetMaxY} returns the maximum number of screen
  391. lines
  392. \Errors
  393. None.
  394. \SeeAlso
  395. \seef{GetMaxY}
  396. \end{function}
  397. \begin{function}{GetModeName}
  398. \Declaration
  399. Function GetModeName (Var modus : Integer) : String;
  400. \Description
  401. Returns a string with the name of modus
  402. \var{Modus}
  403. \Errors
  404. None.
  405. \SeeAlso
  406. \seef{GetDriverName}, \seep{InitGraph}
  407. \end{function}
  408. \begin{procedure}{GetModeRange}
  409. \Declaration
  410. Procedure GetModeRange (Driver : Integer; \\ LoModus, HiModus: Integer);
  411. \Description
  412. \var{GetModeRange} returns the Lowest and Highest modus of the currently
  413. installed driver.
  414. \Errors
  415. None.
  416. \SeeAlso
  417. \seep{InitGraph}
  418. \end{procedure}
  419. \begin{procedure}{GetPalette}
  420. \Declaration
  421. Procedure GetPalette (Var Palette : PaletteType);
  422. \Description
  423. \var{GetPalette} returns in \var{Palette} the current palette.
  424. \Errors
  425. None.
  426. \SeeAlso
  427. \seef{GetPaletteSize}, \seep{SetPalette}
  428. \end{procedure}
  429. \begin{function}{GetPaletteSize}
  430. \Declaration
  431. Function GetPaletteSize : Word;
  432. \Description
  433. \var{GetPaletteSize} returns the maximum
  434. number of entries in the current palette.
  435. \Errors
  436. None.
  437. \SeeAlso
  438. \seep{GetPalette},
  439. \seep{SetPalette}
  440. \end{function}
  441. \begin{function}{GetPixel}
  442. \Declaration
  443. Function GetPixel (X,Y : Integer) : Word;
  444. \Description
  445. \var{GetPixel} returns the color
  446. of the point at \var{(X,Y)}
  447. \Errors
  448. None.
  449. \SeeAlso
  450. \end{function}
  451. \begin{procedure}{GetTextSettings}
  452. \Declaration
  453. Procedure GetTextSettings (Var TextInfo : TextSettingsType);
  454. \Description
  455. \var{GetTextSettings} returns the current text style settings : The font,
  456. direction, size and placement as set with \var{SetTextStyle} and
  457. \var{SetTextJustify}
  458. \Errors
  459. None.
  460. \SeeAlso
  461. \seep{SetTextStyle}, \seep{SetTextJustify}
  462. \end{procedure}
  463. \begin{procedure}{GetViewSettings}
  464. \Declaration
  465. Procedure GetViewSettings (Var ViewPort : ViewPortType);
  466. \Description
  467. \var{GetViewSettings} returns the current view-port and clipping settings in
  468. \var{ViewPort}.
  469. \Errors
  470. None.
  471. \SeeAlso
  472. \seep{SetViewPort}
  473. \end{procedure}
  474. \begin{function}{GetX}
  475. \Declaration
  476. Function GetX : Integer;
  477. \Description
  478. \var{GetX} returns the X-coordinate of the current position of
  479. the graphical pointer
  480. \Errors
  481. None.
  482. \SeeAlso
  483. \seef{GetY}
  484. \end{function}
  485. \begin{function}{GetY}
  486. \Declaration
  487. Function GetY : Integer;
  488. \Description
  489. \var{GetY} returns the Y-coordinate of the current position of
  490. the graphical pointer
  491. \Errors
  492. None.
  493. \SeeAlso
  494. \seef{GetX}
  495. \end{function}
  496. \begin{procedure}{GraphDefaults}
  497. \Declaration
  498. Procedure GraphDefaults ;
  499. \Description
  500. \var{GraphDefaults} resets all settings for view-port, palette,
  501. foreground and background pattern, line-style and pattern, filling style,
  502. filling color and pattern, font, text-placement and
  503. text size.
  504. \Errors
  505. None.
  506. \SeeAlso
  507. \seep{SetViewPort}, \seep{SetFillStyle}, \seep{SetColor},
  508. \seep{SetBkColor}, \seep{SetLineStyle}
  509. \end{procedure}
  510. \begin{function}{GraphErrorMsg}
  511. \Declaration
  512. Function GraphErrorMsg (ErrorCode : Integer) : String;
  513. \Description
  514. \var{GraphErrorMsg}
  515. returns a string describing the error \var{Errorcode}. This string can be
  516. used to let the user know what went wrong.
  517. \Errors
  518. None.
  519. \SeeAlso
  520. \seef{GraphResult}
  521. \end{function}
  522. \begin{function}{GraphResult}
  523. \Declaration
  524. Function GraphResult : Integer;
  525. \Description
  526. \var{GraphResult} returns an error-code for
  527. the last graphical operation. If the returned value is zero, all went well.
  528. A value different from zero means an error has occurred.
  529. Except for all operations which draw something on the screen,
  530. the following procedures also can produce a \var{GraphResult} different from
  531. zero:
  532. \begin{itemize}
  533. \item \seef{InstallUserFont}
  534. \item \seep{SetLineStyle}
  535. \item \seep{SetWriteMode}
  536. \item \seep{SetFillStyle}
  537. \item \seep{SetTextJustify}
  538. \item \seep{SetGraphMode}
  539. \item \seep{SetTextStyle}
  540. \end{itemize}
  541. \Errors
  542. None.
  543. \SeeAlso
  544. \seef{GraphErrorMsg}
  545. \end{function}
  546. \begin{function}{ImageSize}
  547. \Declaration
  548. Function ImageSize (X1,Y1,X2,Y2 : Integer) : Word;
  549. \Description
  550. \var{ImageSize} returns
  551. the number of bytes needed to store the image in the rectangle defined by
  552. \var{(X1,Y1)} and \var{(X2,Y2)}.
  553. \Errors
  554. None.
  555. \SeeAlso
  556. \seep{GetImage}
  557. \end{function}
  558. \begin{procedure}{InitGraph}
  559. \Declaration
  560. Procedure InitGraph (var GraphDriver,GraphModus : integer;\\
  561. const PathToDriver : string);
  562. \Description
  563. \var{InitGraph} initializes the \var{graph} package.
  564. \var{GraphDriver} has two valid values: \var{GraphDriver=0} which
  565. performs an auto detect and initializes the highest possible mode with the most
  566. colors. 1024x768x64K is the highest possible resolution supported by the
  567. driver, if you need a higher resolution, you must edit \file{MODES.PPI}.
  568. If you need another mode, then set \var{GraphDriver} to a value different
  569. from zero
  570. and \var{graphmode} to the mode you wish (VESA modes where 640x480x256
  571. is \var {101h} etc.).
  572. \var{PathToDriver} is only needed, if you use the BGI fonts from
  573. Borland.
  574. \Errors
  575. None.
  576. \SeeAlso
  577. Introduction, (page \pageref{se:Introduction}),
  578. \seep{DetectGraph}, \seep{CloseGraph}, \seef{GraphResult}
  579. \end{procedure}
  580. Example:
  581. \begin{verbatim}
  582. var
  583. gd,gm : integer;
  584. PathToDriver : string;
  585. begin
  586. gd:=detect; { highest possible resolution }
  587. gm:=0; { not needed, auto detection }
  588. PathToDriver:='C:\PP\BGI'; { path to BGI fonts,
  589. drivers aren't needed }
  590. InitGraph(gd,gm,PathToDriver);
  591. if GraphResult<>grok then
  592. halt; ..... { whatever you need }
  593. CloseGraph; { restores the old graphics mode }
  594. end.
  595. \end{verbatim}
  596. \begin{function}{InstallUserDriver}
  597. \Declaration
  598. Function InstallUserDriver (DriverPath : String; \\AutoDetectPtr: Pointer) : Integer;
  599. \Description
  600. \var{InstallUserDriver}
  601. adds the device-driver \var{DriverPath} to the list of .BGI
  602. drivers. \var{AutoDetectPtr} is a pointer to a possible auto-detect function.
  603. \Errors
  604. None.
  605. \SeeAlso
  606. \seep{InitGraph}, \seef{InstallUserFont}
  607. \end{function}
  608. \begin{function}{InstallUserFont}
  609. \Declaration
  610. Function InstallUserFont (FontPath : String) : Integer;
  611. \Description
  612. \var{InstallUserFont} adds the font in \var{FontPath} to the list of fonts
  613. of the .BGI system.
  614. \Errors
  615. None.
  616. \SeeAlso
  617. \seep{InitGraph}, \seef{InstallUserDriver}
  618. \end{function}
  619. \begin{procedure}{Line}
  620. \Declaration
  621. Procedure Line (X1,Y1,X2,Y2 : Integer);
  622. \Description
  623. \var{Line} draws a line starting from
  624. \var{(X1,Y1} to \var{(X2,Y2)}, in the current line style and color. The
  625. current position is put to \var{(X2,Y2)}
  626. \Errors
  627. None.
  628. \SeeAlso
  629. \seep{LineRel},\seep{LineTo}
  630. \end{procedure}
  631. \begin{procedure}{LineRel}
  632. \Declaration
  633. Procedure LineRel (DX,DY : Integer);
  634. \Description
  635. \var{LineRel} draws a line starting from
  636. the current pointer position to the point\var{(DX,DY}, \textbf{relative} to the
  637. current position, in the current line style and color. The Current Position
  638. is set to the endpoint of the line.
  639. \Errors
  640. None.
  641. \SeeAlso
  642. \seep{Line}, \seep{LineTo}
  643. \end{procedure}
  644. \begin{procedure}{LineTo}
  645. \Declaration
  646. Procedure LineTo (DX,DY : Integer);
  647. \Description
  648. \var{LineTo} draws a line starting from
  649. the current pointer position to the point\var{(DX,DY}, \textbf{relative} to the
  650. current position, in the current line style and color. The Current position
  651. is set to the end of the line.
  652. \Errors
  653. None.
  654. \SeeAlso
  655. \seep{LineRel},\seep{Line}
  656. \end{procedure}
  657. \begin{procedure}{MoveRel}
  658. \Declaration
  659. Procedure MoveRel (DX,DY : Integer;
  660. \Description
  661. \var{MoveRel} moves the pointer to the
  662. point \var{(DX,DY)}, relative to the current pointer
  663. position
  664. \Errors
  665. None.
  666. \SeeAlso
  667. \seep{MoveTo}
  668. \end{procedure}
  669. \begin{procedure}{MoveTo}
  670. \Declaration
  671. Procedure MoveTo (X,Y : Integer;
  672. \Description
  673. \var{MoveTo} moves the pointer to the
  674. point \var{(X,Y)}.
  675. \Errors
  676. None.
  677. \SeeAlso
  678. \seep{MoveRel}
  679. \end{procedure}
  680. \begin{procedure}{OutText}
  681. \Declaration
  682. Procedure OutText (Const TextString : String);
  683. \Description
  684. \var{OutText} puts \var{TextString} on the screen, at the current pointer
  685. position, using the current font and text settings. The current position is
  686. moved to the end of the text.
  687. \Errors
  688. None.
  689. \SeeAlso
  690. \seep{OutTextXY}
  691. \end{procedure}
  692. \begin{procedure}{OutTextXY}
  693. \Declaration
  694. Procedure OutTextXY (X,Y : Integer; Const TextString : String);
  695. \Description
  696. \var{OutText} puts \var{TextString} on the screen, at position \var{(X,Y)},
  697. using the current font and text settings. The current position is
  698. moved to the end of the text.
  699. \Errors
  700. None.
  701. \SeeAlso
  702. \seep{OutText}
  703. \end{procedure}
  704. \begin{procedure}{PieSlice}
  705. \Declaration
  706. Procedure PieSlice (X,Y : Integer; \\ Start,Stop,Radius : Word);
  707. \Description
  708. \var{PieSlice}
  709. draws and fills a sector of a circle with center \var{(X,Y)} and radius
  710. \var{Radius}, starting at angle \var{Start} and ending at angle \var{Stop}.
  711. \Errors
  712. None.
  713. \SeeAlso
  714. \seep{Arc}, \seep{Circle}, \seep{Sector}
  715. \end{procedure}
  716. \begin{procedure}{PutImage}
  717. \Declaration
  718. Procedure PutImage (X1,Y1 : Integer; Var Bitmap; How : word) ;
  719. \Description
  720. \var{PutImage}
  721. Places the bitmap in \var{Bitmap} on the screen at \var{(X1,Y1)}. \var{How}
  722. determines how the bitmap will be placed on the screen. Possible values are :
  723. \begin{itemize}
  724. \item CopyPut
  725. \item XORPut
  726. \item ORPut
  727. \item AndPut
  728. \item NotPut
  729. \end{itemize}
  730. \Errors
  731. None
  732. \SeeAlso
  733. \seef{ImageSize},\seep{GetImage}
  734. \end{procedure}
  735. \begin{procedure}{PutPixel}
  736. \Declaration
  737. Procedure PutPixel (X,Y : Integer; Color : Word);
  738. \Description
  739. Puts a point at
  740. \var{(X,Y)} using color \var{Color}
  741. \Errors
  742. None.
  743. \SeeAlso
  744. \seef{GetPixel}
  745. \end{procedure}
  746. \begin{procedure}{Rectangle}
  747. \Declaration
  748. Procedure Rectangle (X1,Y1,X2,Y2 : Integer);
  749. \Description
  750. Draws a rectangle with
  751. corners at \var{(X1,Y1)} and \var{(X2,Y2)}, using the current color and
  752. style.
  753. \Errors
  754. None.
  755. \SeeAlso
  756. \seep{Bar}, \seep{Bar3D}
  757. \end{procedure}
  758. \begin{function}{RegisterBGIDriver}
  759. \Declaration
  760. Function RegisterBGIDriver (Driver : Pointer) : Integer;
  761. \Description
  762. Registers a user-defined BGI driver
  763. \Errors
  764. None.
  765. \SeeAlso
  766. \seef{InstallUserDriver},
  767. \seef{RegisterBGIFont}
  768. \end{function}
  769. \begin{function}{RegisterBGIFont}
  770. \Declaration
  771. Function RegisterBGIFont (Font : Pointer) : Integer;
  772. \Description
  773. Registers a user-defined BGI driver
  774. \Errors
  775. None.
  776. \SeeAlso
  777. \seef{InstallUserFont},
  778. \seef{RegisterBGIDriver}
  779. \end{function}
  780. \begin{procedure}{RestoreCRTMode}
  781. \Declaration
  782. Procedure RestoreCRTMode ;
  783. \Description
  784. Restores the screen modus which was active before
  785. the graphical modus was started.
  786. \Errors
  787. None.
  788. \SeeAlso
  789. \seep{InitGraph}
  790. \end{procedure}
  791. \begin{procedure}{Sector}
  792. \Declaration
  793. Procedure Sector (X,Y : Integer; \\ Start,Stop,XRadius,YRadius : Word);
  794. \Description
  795. \var{Sector}
  796. draws and fills a sector of an ellipse with center \var{(X,Y)} and radii
  797. \var{XRadius} and \var{YRadius}, starting at angle \var{Start} and ending at angle \var{Stop}.
  798. \Errors
  799. None.
  800. \SeeAlso
  801. \seep{Arc}, \seep{Circle}, \seep{PieSlice}
  802. \end{procedure}
  803. \begin{procedure}{SetActivePage}
  804. \Declaration
  805. Procedure SetActivePage (Page : Word);
  806. \Description
  807. Sets \var{Page} as the active page
  808. for all graphical output.
  809. \Errors
  810. None.
  811. \SeeAlso
  812. \end{procedure}
  813. \begin{procedure}{SetAllPallette}
  814. \Declaration
  815. Procedure SetAllPallette (Var Palette);
  816. \Description
  817. Sets the current palette to
  818. \var{Palette}. \var{Palette} is an untyped variable, usually pointing to a
  819. record of type \var{PaletteType}
  820. \Errors
  821. None.
  822. \SeeAlso
  823. \seep{GetPalette}
  824. \end{procedure}
  825. \begin{procedure}{SetAspectRatio}
  826. \Declaration
  827. Procedure SetAspectRatio (Xasp,Yasp : Word);
  828. \Description
  829. Sets the aspect ratio of the
  830. current screen to \var{Xasp/Yasp}.
  831. \Errors
  832. None
  833. \SeeAlso
  834. \seep{InitGraph}, \seep{GetAspectRatio}
  835. \end{procedure}
  836. \begin{procedure}{SetBkColor}
  837. \Declaration
  838. Procedure SetBkColor (Color : Word);
  839. \Description
  840. Sets the background color to
  841. \var{Color}.
  842. \Errors
  843. None.
  844. \SeeAlso
  845. \seef{GetBkColor}, \seep{SetColor}
  846. \end{procedure}
  847. \begin{procedure}{SetColor}
  848. \Declaration
  849. Procedure SetColor (Color : Word);
  850. \Description
  851. Sets the foreground color to
  852. \var{Color}.
  853. \Errors
  854. None.
  855. \SeeAlso
  856. \seef{GetColor}, \seep{SetBkColor}
  857. \end{procedure}
  858. \begin{procedure}{SetFillPattern}
  859. \Declaration
  860. Procedure SetFillPattern (FillPattern : FillPatternType,\\ Color : Word);
  861. \Description
  862. \var{SetFillPattern} sets the current fill-pattern to \var{FillPattern}, and
  863. the filling color to \var{Color}
  864. The pattern is an 8x8 raster, corresponding to the 64 bits in
  865. \var{FillPattern}.
  866. \Errors
  867. None
  868. \SeeAlso
  869. \seep{GetFillPattern}, \seep{SetFillStyle}
  870. \end{procedure}
  871. \begin{procedure}{SetFillStyle}
  872. \Declaration
  873. Procedure SetFillStyle (Pattern,Color : word);
  874. \Description
  875. \var{SetFillStyle} sets the filling pattern and color to one of the
  876. predefined filling patterns. \var{Pattern} can be one of the following predefined
  877. constants :
  878. \begin{itemize}
  879. \item \var{EmptyFill } Uses backgroundcolor.
  880. \item \var{SolidFill } Uses filling color
  881. \item \var{LineFill } Fills with horizontal lines.
  882. \item \var{ltSlashFill} Fills with lines from left-under to top-right.
  883. \item \var{SlashFill } Idem as previous, thick lines.
  884. \item \var{BkSlashFill} Fills with thick lines from left-Top to bottom-right.
  885. \item \var{LtBkSlashFill} Idem as previous, normal lines.
  886. \item \var{HatchFill} Fills with a hatch-like pattern.
  887. \item \var{XHatchFill} Fills with a hatch pattern, rotated 45 degrees.
  888. \item \var{InterLeaveFill}
  889. \item \var{WideDotFill} Fills with dots, wide spacing.
  890. \item \var{CloseDotFill} Fills with dots, narrow spacing.
  891. \item \var{UserFill} Fills with a user-defined pattern.
  892. \end{itemize}
  893. \Errors
  894. None.
  895. \SeeAlso
  896. \seep{SetFillPattern}
  897. \end{procedure}
  898. \begin{procedure}{SetGraphBufSize}
  899. \Declaration
  900. Procedure SetGraphBufSize (BufSize : Word);
  901. \Description
  902. \var{SetGraphBufSize}
  903. sets the graphical buffer size. The default size is 4Kb
  904. \Errors
  905. None.
  906. \SeeAlso
  907. \end{procedure}
  908. \begin{procedure}{SetGraphMode}
  909. \Declaration
  910. Procedure SetGraphMode (Mode : Integer);
  911. \Description
  912. \var{SetGraphMode} sets the
  913. graphical mode and clears the screen.
  914. \Errors
  915. None.
  916. \SeeAlso
  917. \seep{InitGraph}
  918. \end{procedure}
  919. \begin{procedure}{SetLineStyle}
  920. \Declaration
  921. Procedure SetLineStyle (LineStyle,Pattern,Width :
  922. Word);
  923. \Description
  924. \var{SetLineStyle}
  925. sets the drawing style for lines. You can specify a \var{LineStyle} which is
  926. one of the following pre-defined constants:
  927. \begin{itemize}
  928. \item \var{Solidln=0;} draws a solid line.
  929. \item \var{Dottedln=1;} Draws a dotted line.
  930. \item \var{Centerln=2;} draws a non-broken centered line.
  931. \item \var{Dashedln=3;} draws a dashed line.
  932. \item \var{UserBitln=4;} Draws a User-defined bit pattern.
  933. \end{itemize}
  934. If \var{UserBitln} is specified then \var{Pattern} contains the bit pattern.
  935. In all another cases, \var{Pattern} is ignored. The parameter \var{Width}
  936. indicates how thick the line should be. You can specify one of the following
  937. pre-defined constants:
  938. \begin{itemize}
  939. \item \var{NormWidth=1}
  940. \item \var{ThickWidth=3}
  941. \end{itemize}
  942. \Errors
  943. None.
  944. \SeeAlso
  945. \seep{GetLineSettings}
  946. \end{procedure}
  947. \begin{procedure}{SetPalette}
  948. \Declaration
  949. Procedure SetPalette (ColorNr : Word; NewColor : ShortInt);
  950. \Description
  951. \var{SetPalette} changes the \var{ColorNr}-th entry in the palette to
  952. \var{NewColor}
  953. \Errors
  954. None.
  955. \SeeAlso
  956. \seep{SetAllPallette},\seep{SetRGBPalette}
  957. \end{procedure}
  958. \begin{procedure}{SetRGBPalette}
  959. \Declaration
  960. Procedure SetRGBPalette (ColorNr,Red,Green,Blue : Integer);
  961. \Description
  962. \var{SetRGBPalette} sets the \var{ColorNr}-th entry in the palette to the
  963. color with RGB-values \var{Red, Green Blue}.
  964. \Errors
  965. None.
  966. \SeeAlso
  967. \seep{SetAllPallette},
  968. \seep{SetPalette}
  969. \end{procedure}
  970. \begin{procedure}{SetTextJustify}
  971. \Declaration
  972. Procedure SetTextJustify (Horizontal,Vertical : Word);
  973. \Description
  974. \var{SetTextJustify} controls the placement of new text, relative to the
  975. (graphical) cursor position. \var{Horizontal} controls horizontal placement, and can be
  976. one of the following pre-defined constants:
  977. \begin{itemize}
  978. \item \var{LeftText=0;} Text is set left of the pointer.
  979. \item \var{CenterText=1;} Text is set centered horizontally on the pointer.
  980. \item \var{RightText=2;} Text is set to the right of the pointer.
  981. \end{itemize}
  982. \var{Vertical} controls the vertical placement of the text, relative to the
  983. (graphical) cursor position. Its value can be one of the following
  984. pre-defined constants :
  985. \begin{itemize}
  986. \item \var{BottomText=0;} Text is placed under the pointer.
  987. \item \var{CenterText=1;} Text is placed centered vertically on the pointer.
  988. \item \var{TopText=2;}Text is placed above the pointer.
  989. \end{itemize}
  990. \Errors
  991. None.
  992. \SeeAlso
  993. \seep{OutText}, \seep{OutTextXY}
  994. \end{procedure}
  995. \begin{procedure}{SetTextStyle}
  996. \Declaration
  997. Procedure SetTextStyle (Font,Direction,Magnitude : Word);
  998. \Description
  999. \var{SetTextStyle} controls the style of text to be put on the screen.
  1000. pre-defined constants for \var{Font} are:
  1001. \begin{itemize}
  1002. \item \var{DefaultFont=0;}
  1003. \item \var{TriplexFont=2;}
  1004. \item \var{SmallFont=2;}
  1005. \item \var{SansSerifFont=3;}
  1006. \item \var{GothicFont=4;}
  1007. \end{itemize}
  1008. Pre-defined constants for \var{Direction} are :
  1009. \begin{itemize}
  1010. \item \var{HorizDir=0;}
  1011. \item \var{VertDir=1;}
  1012. \end{itemize}
  1013. \Errors
  1014. None.
  1015. \SeeAlso
  1016. \seep{GetTextSettings}
  1017. \end{procedure}
  1018. \begin{procedure}{SetUserCharSize}
  1019. \Declaration
  1020. Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
  1021. \Description
  1022. Sets the width and height of vector-fonts. The horizontal size is given
  1023. by \var{Xasp1/Xasp2}, and the vertical size by \var{Yasp1/Yasp2}.
  1024. \Errors
  1025. None.
  1026. \SeeAlso
  1027. \seep{SetTextStyle}
  1028. \end{procedure}
  1029. \begin{procedure}{SetViewPort}
  1030. \Declaration
  1031. Procedure SetViewPort (X1,Y1,X2,Y2 : Integer; Clip : Boolean);
  1032. \Description
  1033. Sets the current graphical view-port (window) to the rectangle defined by
  1034. the top-left corner \var{(X1,Y1)} and the bottom-right corner \var{(X2,Y2)}.
  1035. If \var{Clip} is true, anything drawn outside the view-port (window) will be
  1036. clipped (i.e. not drawn). Coordinates specified after this call are relative
  1037. to the top-left corner of the view-port.
  1038. \Errors
  1039. None.
  1040. \SeeAlso
  1041. \seep{GetViewSettings}
  1042. \end{procedure}
  1043. \begin{procedure}{SetVisualPage}
  1044. \Declaration
  1045. Procedure SetVisualPage (Page : Word);
  1046. \Description
  1047. \var{SetVisualPage} sets the video page to page number \var{Page}.
  1048. \Errors
  1049. None
  1050. \SeeAlso
  1051. \seep{SetActivePage}
  1052. \end{procedure}
  1053. \begin{procedure}{SetWriteMode}
  1054. \Declaration
  1055. Procedure SetWriteMode (Mode : Integer);
  1056. \Description
  1057. \var{SetWriteMode} controls the drawing of lines on the screen. It controls
  1058. the binary operation used when drawing lines on the screen. \var{Mode} can
  1059. be one of the following pre-defined constants:
  1060. \begin{itemize}
  1061. \item CopyPut=0;
  1062. \item XORPut=1;
  1063. \end{itemize}
  1064. \Errors
  1065. None.
  1066. \SeeAlso
  1067. \end{procedure}
  1068. \begin{function}{TextHeight}
  1069. \Declaration
  1070. Function TextHeight (S : String) : Word;
  1071. \Description
  1072. \var{TextHeight} returns the height (in pixels) of the string \var{S} in
  1073. the current font and text-size.
  1074. \Errors
  1075. None.
  1076. \SeeAlso
  1077. \seef{TextWidth}
  1078. \end{function}
  1079. \begin{function}{TextWidth}
  1080. \Declaration
  1081. Function TextWidth (S : String) : Word;
  1082. \Description
  1083. \var{TextHeight} returns the width (in pixels) of the string \var{S} in
  1084. the current font and text-size.
  1085. \Errors
  1086. None.
  1087. \SeeAlso
  1088. \seef{TextHeight}
  1089. \end{function}