graph.tex 30 KB

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