graph.tex 32 KB

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