graph.tex 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997,1999 by the Free Pascal Development team
  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. % Carl Eric Codere, April 1999
  24. \chapter{The GRAPH unit.}
  25. This document describes the \textbf{GRAPH} unit for Free Pascal. This unit includes
  26. more then 50 graphics routines, that range from low-level calls such as putpixel
  27. to high level calls like Circle and Bar3D. Different fill styles and line
  28. patterns are supported in most of the routines.
  29. \section{Overview}
  30. \label{se:Overview}
  31. \subsection{Compatibility}
  32. Since the graph unit included with \var{fpc} is a portable implementation of
  33. the Turbo Pascal unit, there are some slight differences between the video
  34. modes and features.
  35. \subsubsection{Initialization}
  36. Each graph unit implementation, will have a 320x200 resolution refered to
  37. \textit{LowResolution}. If the hardware for the specific platform does
  38. not support that resolution, then it will have to be emulated. Apart
  39. from that requirement, all other resolutions will be dependant on the
  40. target platform.
  41. The correct way and portable way to initialize to graphics subsystem, is
  42. to first query the hardware, and then from that, decide which mode you
  43. wish to support. The routine which does this is called \textit{QueryAdapterInfo}.
  44. This routine returns a linked list of modes availables, and their
  45. mode number as well as driver numbers. It is to note that this list is
  46. initialized only once during the lifetime of the application (that is,
  47. even if CloseGraph is called, the list will still be valid). The memory
  48. allocated for this list is automatically freed as part as the graph
  49. unit's exit procedure.
  50. You can always use Detect as a parameter to \textit{InitGraph}
  51. which will initialize the graphics to the highest resolution possible.
  52. The following constants are also defined for compatiblity with older
  53. applications written with Turbo Pascal, they should no longer be used:
  54. \begin{tabular}{|c|c|c|}
  55. \hline
  56. Driver Name & Constant Name & Column x Row & Colors \\ \hline
  57. HercMono & HercMonoHi & 720x348 & 1 \\
  58. VGA & VGAHi & 640x480 & 16 \\
  59. VGA & VGA256 & 320x200 & 256 \\
  60. \hline
  61. \end{tabular}
  62. \subsubsection{Other differences}
  63. Some notable differences with the Turbo Pascal graph unit are noted
  64. below:
  65. \begin{itemize}
  66. \item \textit{Rectangle} do not write
  67. the end points twice, which permits the XORPut write mode to be used
  68. effectively for erasing these forms on the screen.
  69. \item \textit{RegisterBGIDriver} and \textit{InstallUserDriver} always
  70. return errors, as they are not directly supported.
  71. \item \textit{DrawPoly} XORPut write mode does not have the same behaviour
  72. as the one in the Turbo Pascal graph unit.
  73. \item XORPut write mode is not supported by \textit{FillEllipse}.
  74. \item XORPut write mode is not supported by \textit{Bar3d}.
  75. \item Passing invalid parameters to \textit{SetTextStyle} will not
  76. result in the same visual appearance. Make sure your input is valid.
  77. \item All routines using sines/cosines (e.g: \textit{circle}), don't
  78. exactly have the same radii, because the aspect ratio correction is
  79. different.
  80. \item PutImage supports clipping.
  81. \item \textit{SetRGBPalette} use the LSB's of the RGB components to
  82. set the color values of the palette. This makes the unit more portable.
  83. \item \textit{PaletteType} is different then the Turbo Pascal version,
  84. it uses RGB Values for the palettes.
  85. \item \textit{SetAllPalette} is different then the Turbo Pascal version,
  86. it uses the PaletteType as a parameter.
  87. \item \textit{GetDefaultPalette} only returns only at most the 256 first
  88. default entries of a palette, even if the mode supports more then
  89. 256 colors.
  90. \end{itemize}
  91. \subsection{Coordinate system}
  92. The upper left of the graphics screen is located at position (0,0). The x
  93. value, which represents the column, increments to the right. The y values,
  94. or rows, increment downward. The maximum value which can be set for an x
  95. value, for the graphics screen is given by the \textit{GetMaxX} routine.
  96. The same is true for the y coordinate, except a call to \textit{GetMaxY}
  97. is required.
  98. \subsection{Current pointer}
  99. Some graphics routines support the concept of the current pointer (CP). The
  100. current pointer is similar in concept to a text cursor, except that it is
  101. invisible.
  102. When you write in text mode, the text cursor is automatically incremented
  103. by the number of characters written. The same is true with the graphics
  104. current pointer, which is instead incremented on a pixel basis.
  105. For example, the following:
  106. \begin{verbatim}
  107. MoveTo(0,0);
  108. LineTo(100,100);
  109. \end{verbatim}
  110. will leave the current pointer to the (100,100) coordinate pair. The
  111. pixels might not be drawn depending on your clipping settings, but the
  112. CP is never clipped to clipping boundaries.
  113. The following routines set the CP to the new position:
  114. \begin{itemize}
  115. \item \textit{ClearDevice}
  116. \item \textit{ClearViewPort}
  117. \item \textit{GraphDefaults}
  118. \item \textit{InitGraph}
  119. \item \textit{LineRel}
  120. \item \textit{LineTo}
  121. \item \textit{MoveRel}
  122. \item \textit{MoveTo}
  123. \item \textit{OutText}
  124. \item \textit{SetGraphMode}
  125. \item \textit{SetViewPort}
  126. \end{itemize}
  127. \subsection{Error handling}
  128. There is only basic error checking in the graph unit. To get the value of
  129. the last error returned by a graphics driver call, call the
  130. \textit{GraphResult} routine. The following routines can set error codes,
  131. others don't :
  132. \begin{itemize}
  133. \item \textit{Bar} --- ok
  134. \item \textit{Bar3D} --- ok
  135. \item \textit{ClearViewPort}
  136. \item \textit{CloseGraph}
  137. \item \textit{DetectGraph}
  138. \item \textit{DrawPoly} --- ok
  139. \item \textit{FillPoly} --- ok
  140. \item \textit{FloodFill} --- ok
  141. \item \textit{GetModeName} --- ok
  142. \item \textit{GetRGBPalette} --- ok
  143. \item \textit{InitGraph} --- ok
  144. \item \textit{InstallUserDriver} --- ok
  145. \item \textit{InstallUserFont} --- ok
  146. \item \textit{PieSlice}
  147. \item \textit{RegisterBGIDriver} --- ok
  148. \item \textit{RegisterBGIFont} --- ok
  149. \item \textit{SetAllPalette} --- ok
  150. \item \textit{SetFillPattern} --- ok
  151. \item \textit{SetFillStyle} --- ok
  152. \item \textit{SetGraphBufSize}
  153. \item \textit{SetGraphMode}
  154. \item \textit{SetLineStyle} --- ok
  155. \item \textit{SetPalette} --- ok
  156. \item \textit{SetRGBPalette} --- ok
  157. \item \textit{SetTextJustify} --- ok
  158. \item \textit{SetTextStyle} --- ok
  159. \item \textit{SetViewPort} --- ok
  160. \end{itemize}
  161. \textit{GraphResult} is reset to zero after it has been called. Therefore
  162. the user should store the value returned by this function into a temporary
  163. variable and then use it.
  164. \subsection{Write modes}
  165. Write modes permits combining colors with already existing on-screen colors,
  166. \textit{PutImage} supports several write modes, while most other routines
  167. support only CopyPut/NormalPut and XORPut modes.
  168. The following routines support XORPut write modes (all routines support
  169. CopyPut modes):
  170. \begin{itemize}
  171. \item \textit{FillPoly}
  172. \item \textit{Arc} with ThickWidth line styles only
  173. \item \textit{Circle} with ThickWidth line styles only
  174. \item \textit{Line}
  175. \item \textit{LineRel}
  176. \item \textit{LineTo}
  177. \item \textit{Rectangle}
  178. \item \textit{DrawPoly}
  179. \end{itemize}
  180. \subsection{Text}
  181. An internal bitmap font is included with this implementation of the graph
  182. unit. It also possible to load and use standard Borland CHR external
  183. vectorized font files. A bitmapped font is defined in this case by
  184. a matrix of 8x8 pixels. A vector font (also referred to as a stroked font)
  185. is defined by a series of vectors that tell the graphics system how to draw
  186. the font.
  187. \subsection{Clipping and Viewports}
  188. \textit{SetViewPort} makes all output commands operate in a rectangular
  189. region of the screen. Most output routines are viewport relative until
  190. the viewport is changed. If clipping is active, all graphics is output
  191. is clipped to the current region.
  192. There is always clipping to the screen boundaries, whatever the clipping
  193. setting is.
  194. \subsection{Internals}
  195. To make porting to a new platform easier, some of the graph unit routines
  196. have been designed using procedural variables. Some of the routines have
  197. default hooks, while others must absolutely be implemented for every new
  198. platform to make the graph unit work.
  199. The following routines must be created for every new platform supported:
  200. \begin{itemize}
  201. \item \textit{CloseGraph}
  202. \item \textit{DirectPutPixel}
  203. \item \textit{PutPixel}
  204. \item \textit{GetPixel}
  205. \item \textit{InitMode}
  206. \item \textit{SaveVideoState}
  207. \item \textit{RestoreVideoState}
  208. \item \textit{QueryAdapterInfo}
  209. \item \textit{SetRGBPalette}
  210. \item \textit{GetRGBPalette}
  211. \end{itemize}
  212. The following global variables must be setup for every new platform
  213. supported:
  214. InternalDriverName
  215. \var{InternalDriverName}
  216. This variable should be set to a string describing the platform driver
  217. name. It is returned by the user function GetDriverName. Some examples
  218. of driver names are 'DosGX', 'DirectX', 'QuickDrw','CyberGFX', 'Dive'.
  219. \var{CloseGraph}
  220. The CloseGraph routine is called directly by the user and must
  221. do the necessary cleanup by freeing up all platform specific
  222. memory allocations, and by calling RestoreVideoState.
  223. \var{DirectPutPixel}
  224. This routine is one of the most important callback routines with
  225. PutPixel, it is called by most of the routines in the graph unit. It
  226. is about the same as PutPixel except that the coordinates passed to
  227. it are already in global (screen) coordinates, and that clipping has
  228. already been performed.
  229. \var{InitMode}
  230. This callback routine is called by SetGraphMode to actualliy change to
  231. the correct video mode. (SetGraphMode is called by InitGraph).
  232. \var{SaveVideoState}
  233. This routine is called by InitGraph before changing to the graphics video
  234. mode, it should save the old video mode, save any internal video state
  235. such as the palette entries.
  236. \var{RestoreVideoState}
  237. This routine should be called by CloseGraph, it should restore the video
  238. mode to the one saved in SaveVideoState, and restore all appropriate video
  239. information, so that the video is in the same state as it was when
  240. SaveVideoState was called.
  241. \var{QueryAdapterInfo}
  242. This routine might be called by the user BEFORE we are in graphics
  243. mode. In all cases it is called by DetectGraph and InitGraph. It
  244. creates a linked list of video capabilities and procedural hooks for
  245. all supported video modes on the platform. Look at the DOS version,
  246. to see how it works. This linked list can be read by the user before a
  247. call to InitGraph to determine which mode to use.
  248. The linked list is composed of mode information, as well to pointers
  249. to the callback routines cited above. Some additional optional hooks
  250. are also possible for those who wish to optimize the speed of the unit.
  251. -------------------------------------------------------------
  252. \begin{function}{GetModeName}
  253. \Declaration
  254. Function GetModeName (ModeNumber : Integer) : String;
  255. \Description
  256. Returns a string with the name of the specified graphics mode. The
  257. return values are in the form, XRes x YRes NAME. This function is
  258. useful for building menus, display status, and so forth.
  259. \Errors
  260. If the specified \var{ModeNumber} is invalid, the function returns an
  261. empty string and sets GraphResult to grInvalidMode.
  262. \SeeAlso
  263. \seef{GetDriverName}, \seep{GetModeRange}, \seep{GetMaxMode}
  264. \end{function}
  265. ------------------------
  266. \begin{procedure}{SetAllPalette}
  267. \Declaration
  268. Procedure SetAllPalette(var Palette: PaletteType) ;
  269. \Description
  270. \var{Palette} is of type PaletteType. Thie first field in Palette
  271. contains the length of the palette. The next \textit{n} fields of
  272. type \var{RGBRec} contains the Red-Green-Blue components to replace
  273. that specific color with. A value of -1 will not change the previous
  274. entry's value.
  275. Note that valid colors depend on the current graphics mode.
  276. If the number of palette entries to replace is greater then the
  277. number of colors possible on the screen, \var{GraphResult} returns
  278. a value of \var{grError} and no changes to the palette settings will
  279. occur.
  280. Changes to the palette take effect immediately on the screen. Each time
  281. a palette color is changed, that color will be changed to the new color
  282. value.
  283. This routine returns \var{grError} if called in a direct color mode.
  284. \Errors
  285. None.
  286. \SeeAlso
  287. \seep{SetRGBPalette}, \seep{SetPalette}
  288. \end{procedure}
  289. ------------------------
  290. ------------------------
  291. \begin{procedure}{GetDefaultPalette}
  292. \Declaration
  293. Procedure GetDefaultPalette (Var Palette : PaletteType);
  294. \Description
  295. Returns a \var{PaletteType} record containing the default RGB color
  296. values when the graphics mode is initialized. These values are based
  297. on the IBM-PC VGA hardware adapter, but do not change from platform
  298. to platform.
  299. On other platforms the colors may not exactly match those
  300. on the IBM-PC, but the match should be close enough for most uses. This
  301. value is static and does never change.
  302. Even if the modes can support more then 256 color entries, only the
  303. 256 first colors can be considered as having default values. Therefore,
  304. at most this function will return 256 entries. To query all colors over
  305. 256 yourself, use \var{GetRGBPalette} for the entire palette range.
  306. \Errors
  307. None.
  308. \SeeAlso
  309. \seef{GetColor}, \seef{GetBkColor}, \seep{GetRGBPalette}
  310. \end{procedure}
  311. ------------------------
  312. \begin{procedure}{GetPalette}
  313. \Declaration
  314. Procedure GetPalette (Var Palette : PaletteType);
  315. \Description
  316. \var{GetPalette} returns in \var{Palette} the current palette. The palette
  317. is in LSB RGB format.
  318. This routine returns \var{grError} if called in a direct color mode.
  319. \Errors
  320. None.
  321. \SeeAlso
  322. \seef{GetPaletteSize}, \seep{SetPalette}
  323. \end{procedure}
  324. ---------------------------
  325. ---------------------------
  326. \begin{function}{GetBkColor}
  327. \Declaration
  328. Function GetBkColor : Word;
  329. \Description
  330. \var{GetBkColor} returns the current background color. If in non direct color
  331. mode, this returns the palette entry, otherwise it returns the direct
  332. RGB value of the current drawing color.
  333. \Errors
  334. None.
  335. \SeeAlso
  336. \seef{GetColor},\seep{SetBkColor}
  337. \end{function}
  338. ---------------------------
  339. \begin{function}{GetColor}
  340. \Declaration
  341. Function GetColor : Word;
  342. \Description
  343. \var{GetColor} returns the current drawing color. If in non direct color
  344. mode, this returns the palette entry, otherwise it returns the direct
  345. RGB value of the current drawing color.
  346. \Errors
  347. None.
  348. \SeeAlso
  349. \seef{GetColor},\seep{SetBkColor}
  350. \end{function}
  351. ---------------------------
  352. \begin{procedure}{GetRGBPalette}
  353. \Declaration
  354. Procedure GetRGBPalette (ColorNum: intege; var Red,Green,Blue : Integer);
  355. \Description
  356. \var{GetRGBPalette} gets the \var{ColorNum}-th entry in the palette.
  357. The Red , Green and Blue values returned arein LSB format.
  358. If the palette entry could not be read for a reason,
  359. the routine returns \var{grError}.
  360. This routine returns \var{grError} if called in a direct color mode.
  361. \Errors
  362. None.
  363. \SeeAlso
  364. \seep{SetAllPallette},
  365. \seep{SetPalette}
  366. \seep{SetRGBPalette}
  367. \end{procedure}
  368. ----------------------------
  369. ----------------------------
  370. \begin{procedure}{SetDirectVideo}
  371. \Declaration
  372. Procedure SetDirectVideo (DirectAccess : boolean);
  373. \Description
  374. Determines how the video access should be done, if DirectAccess
  375. is set to TRUE then access will be done directly to video memory, if
  376. it is supported, otherwise Operating systems calls will be done to
  377. access the video memory.
  378. The behaviour of this routine depends on the platform, and is required
  379. for example to use the graph unit under older multitaskers such as
  380. Desqview (DOS platform). Certain modes simply are simply not supported
  381. via Operating system calls, while others are only supported by the
  382. operating system. In those cases this routine is simply ignored.
  383. Using operating system calls to plot pixels is much slower then using
  384. the direct mode, but it provides more compatibility.
  385. \textbf{Platform specific}
  386. Windows NT, OS/2, Windows '9x, Windows 3.x, Linux DOSEMU support
  387. all \textit{standard} video DOS modes, even in DirectVideo mode.
  388. Others, like Desqview, Topview, DoubleDOS and MultiDOS might not.
  389. In that case, \vaR{SetDirectVideo} should be called and set to FALSE.
  390. VESA modes are not considered as standard DOS video modes,
  391. and should simply not be used under such multitaskers/emulators.
  392. Mode-X is not considered a standard DOS mode, but is supported in
  393. most modern operating systems, since it uses only standard VGA
  394. I/O ports and memory. (Exception: older multitaskers such as Desqview).
  395. NOT IMPLEMENTED YET.
  396. \Errors
  397. None.
  398. \SeeAlso
  399. \seef{GetDirectVideo}
  400. \end{procedure}
  401. ----------------------------
  402. \begin{function}{GetDirectVideo}
  403. \Declaration
  404. Function GetDirectVideo : boolean;
  405. \Description
  406. Returns the state of the of DirectAccess flag. If this value returns
  407. TRUE, then in the case where it is possible, the video memory is directly
  408. accessed to plot graphics points, otherwise operating system calls
  409. are used.
  410. \Errors
  411. None.
  412. \SeeAlso
  413. \seep{SetDirectVideo}
  414. \end{procedure}
  415. ----------------------------
  416. \section{Reference}
  417. \section{Constants, Types and Variables}
  418. \subsection{Types}
  419. \begin{verbatim}
  420. ArcCoordsType = record
  421. X,Y,Xstart,Ystart,Xend,Yend : Integer;
  422. end;
  423. FillPatternType = Array [1..8] of Byte;
  424. FillSettingsType = Record
  425. Pattern,Color : Word
  426. end;
  427. LineSettingsType = Record
  428. LineStyle,Pattern, Width : Word;
  429. end;
  430. PointType = Record
  431. X,Y : Integer;
  432. end;
  433. TextSettingsType = Record
  434. Font,Direction, CharSize, Horiz, Vert : Word
  435. end;
  436. ViewPortType = Record
  437. X1,Y1,X2,Y2 : Integer;
  438. Clip : Boolean
  439. end;
  440. \end{verbatim}
  441. \begin{verbatim}
  442. PaletteType = Record
  443. Size : longint;
  444. Colors : array[0..MaxColors] of RGBRec;
  445. end;
  446. \end{verbatim}
  447. This record is used by \textit{SetAllPalette} , \textit{GetPalette} and
  448. \textit{GetDefaultPalette}. \textit{Size} indicated the number of RGB
  449. entries in this record, followed by the RGB records for each color. It
  450. is to note, that contrary to Turbo Pascal, the RGB components are in
  451. the LSB's of the RGB component records. This makes easier compatibility
  452. across different hardware platforms.
  453. \section{Functions and procedures}
  454. \begin{procedure}{Arc}
  455. \Declaration
  456. Procedure Arc (X,Y : Integer; stAngle,Endangle, radius : Word);
  457. \Description
  458. \var{Arc} draws part of a circle with center at \var{(X,Y)}, radius
  459. \var{radius}, starting from angle \var{stAngle}, stopping at angle \var{EndAngle}.
  460. These angles are measured counterclockwise. Information about the last call
  461. to \var{Arc} can be retrieved by \var{GetArcCoords}.
  462. \Errors
  463. None.
  464. \SeeAlso
  465. \seep{Circle},\seep{Ellipse}
  466. \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
  467. \end{procedure}
  468. \begin{procedure}{Bar}
  469. \Declaration
  470. Procedure Bar (X1,Y1,X2,Y2 : Integer);
  471. \Description
  472. Draws a rectangle with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
  473. and fills it with the current color and fill-style.
  474. \Errors
  475. None.
  476. \SeeAlso
  477. \seep{Bar3D},
  478. \seep{Rectangle}
  479. \end{procedure}
  480. \begin{procedure}{Bar3D}
  481. \Declaration
  482. Procedure Bar3D (X1,Y1,X2,Y2 : Integer; depth : Word; Top : Boolean);
  483. \Description
  484. Draws a 3-dimensional Bar with corners at \var{(X1,Y1)} and \var{(X2,Y2)}
  485. and fills it with the current color and fill-style.
  486. \var{Depth} specifies the number of pixels used to show the depth of the
  487. bar.
  488. If \var{Top} is true; then a 3-dimensional top is drawn.
  489. \Errors
  490. None.
  491. \SeeAlso
  492. \seep{Bar}, \seep{Rectangle}
  493. \end{procedure}
  494. \begin{procedure}{Circle}
  495. \Declaration
  496. Procedure Circle (X,Y : Integer; Radius : Word);
  497. \Description
  498. \var{Circle} draws part of a circle with center at \var{(X,Y)}, radius
  499. \var{radius} in the current color. Each graphics driver contains an
  500. aspect ratio used by \var{Circle}, \var{Arc} and \var{PieSlice}.
  501. \Errors
  502. None.
  503. \SeeAlso
  504. \seep{Ellipse},\seep{Arc}
  505. \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
  506. \end{procedure}
  507. \begin{procedure}{ClearDevice}
  508. \Declaration
  509. Procedure ClearDevice ;
  510. \Description
  511. Clears the graphical screen (with the current
  512. background color), and sets the pointer at \var{(0,0)}
  513. \Errors
  514. None.
  515. \SeeAlso
  516. \seep{ClearViewPort}, \seep{SetBkColor}
  517. \end{procedure}
  518. \begin{procedure}{ClearViewPort}
  519. \Declaration
  520. Procedure ClearViewPort ;
  521. \Description
  522. Clears the current viewport. The current background color is used as filling
  523. color. The pointer is set at \var{(0,0)}
  524. \Errors
  525. None.
  526. \SeeAlso
  527. \seep{ClearDevice},\seep{SetViewPort}, \seep{SetBkColor}
  528. \end{procedure}
  529. \begin{procedure}{CloseGraph}
  530. \Declaration
  531. Procedure CloseGraph ;
  532. \Description
  533. Closes the graphical system, restores the
  534. screen mode which was active before the graphical mode was
  535. activated and frees up any memory allocated in InitGraph.
  536. \Errors
  537. None.
  538. \SeeAlso
  539. \seep{InitGraph}
  540. \end{procedure}
  541. \begin{procedure}{DetectGraph}
  542. \Declaration
  543. Procedure DetectGraph (Var Driver, Modus : Integer);
  544. \Description
  545. Checks the hardware in the PC and determines the driver and screen-modus to
  546. be used. These are returned in \var{Driver} and \var{Modus}, and can be fed
  547. to \var{InitGraph}.
  548. See the \var{InitGraph} for a list of drivers and modi.
  549. \Errors
  550. None.
  551. \SeeAlso
  552. \seep{InitGraph}
  553. \end{procedure}
  554. \begin{procedure}{DrawPoly}
  555. \Declaration
  556. Procedure DrawPoly (NumPoints : Word; Var PolyPoints);
  557. \Description
  558. Draws a polygon with \var{NumPoints} corner points, using the
  559. current color and linestyle. PolyPoints is an array of type \var{PointType}.
  560. If there are less the two points in \var{PolyPoints}, this routine
  561. returns \var{grError}.
  562. \Errors
  563. None.
  564. \SeeAlso
  565. \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
  566. \end{procedure}
  567. \begin{procedure}{Ellipse}
  568. \Declaration
  569. Procedure Ellipse (X,Y : Integer; StAngle,EndAngle,XRadius,YRadius : Word);
  570. \Description
  571. \var{Ellipse} draws part of an ellipse with center at \var{(X,Y)}.
  572. \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
  573. ellipse. \var{StAngle} and \var{EndAngle} are the starting and stopping angles of
  574. the part of the ellipse. They are measured counterclockwise from the X-axis.
  575. Information about the last call to \var{Ellipse} can be retrieved by
  576. \var{GetArcCoords}.
  577. \Errors
  578. None.
  579. \SeeAlso
  580. \seep{Arc} \seep{Circle}, \seep{FillEllipse}
  581. \end{procedure}
  582. \begin{procedure}{FillEllipse}
  583. \Declaration
  584. Procedure FillEllipse (X,Y : Integer; Xradius,YRadius: Word);
  585. \Description
  586. \var{Ellipse} draws an ellipse with center at \var{(X,Y)}.
  587. \var{XRadius} and \var{Yradius} are the horizontal and vertical radii of the
  588. ellipse. The ellipse is filled with the current color and fill style.
  589. \Errors
  590. None.
  591. \SeeAlso
  592. \seep{Arc} \seep{Circle},
  593. \seep{GetArcCoords},\seep{PieSlice}, \seep{Sector}
  594. \end{procedure}
  595. \begin{procedure}{FillPoly}
  596. \Declaration
  597. Procedure FillPoly (NumberPoints : Word; Var PolyPoints);
  598. \Description
  599. Draws a polygon with \var{NumPoints} corner points and fills it
  600. using the current color and fill style. The outline of the polygon
  601. is drawn in the current line style and color as set by \var{SetLineStyle}.
  602. PolyPoints is an array of type \var{PointType}.
  603. \Errors
  604. None.
  605. \SeeAlso
  606. \seep{Bar}, seep{Bar3D}, \seep{Rectangle}
  607. \end{procedure}
  608. \begin{procedure}{FloodFill}
  609. \Declaration
  610. Procedure FloodFill (X,Y : Integer; BorderColor : Word);
  611. \Description
  612. Fills the area containing the point \var{(X,Y)}, bounded by the color
  613. \var{BorderColor}. The flooding is done using the current fill style
  614. and fill color, as set by \var{SetFillStyle} or \var{SetFillPattern}.
  615. This routine is here for compatibility only, \var{FillPoly} should be
  616. used instead, since it is much faster.
  617. \Errors
  618. None
  619. \SeeAlso
  620. \seep{FillPoly},
  621. \end{procedure}
  622. \begin{procedure}{GetArcCoords}
  623. \Declaration
  624. Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
  625. \Description
  626. \var{GetArcCoords} returns the coordinates of the last \var{Arc} or
  627. \var{Ellipse} call. The values are useful for connecting a line to
  628. the end of an ellipse.
  629. \Errors
  630. None.
  631. \SeeAlso
  632. \seep{Arc}, \seep{Ellipse}
  633. \end{procedure}
  634. \begin{procedure}{GetAspectRatio}
  635. \Declaration
  636. Procedure GetAspectRatio (Var Xasp,Yasp : Word);
  637. \Description
  638. \var{GetAspectRatio} determines the effective resolution of the screen. The aspect ration can
  639. the be calculated as \var{Xasp/Yasp}.
  640. Each graphics driver uses this aspect ratio to make circles and any circular
  641. shape look round on the screen.
  642. \Errors
  643. None.
  644. \SeeAlso
  645. \seep{InitGraph},\seep{SetAspectRatio}
  646. \end{procedure}
  647. \begin{function}{GetDriverName}
  648. \Declaration
  649. Function GetDriverName : String;
  650. \Description
  651. \var{GetDriverName} returns a string containing the name of the
  652. current driver. This name can be anything under FPC, but it is
  653. usually indicative of the API and/or platform used to perform the
  654. graphics call.
  655. \Errors
  656. None.
  657. \SeeAlso
  658. \seef{GetModeName}, \seep{InitGraph}
  659. \end{function}
  660. \begin{procedure}{GetFillPattern}
  661. \Declaration
  662. Procedure GetFillPattern (Var FillPattern : FillPatternType);
  663. \Description
  664. \var{GetFillPattern} returns an array with the current fill pattern in \var{FillPattern}.
  665. If no user call has been made to \var{SetFillPattern}, the pattern will be
  666. filled with \var{$FF}.
  667. It is to note that the user fill pattern is reset to \var{$FF} each time
  668. \var{GraphDefaults} is called.
  669. \Errors
  670. None
  671. \SeeAlso
  672. \seep{SetFillPattern}, \seep{GraphDefaults}
  673. \end{procedure}
  674. \begin{procedure}{GetFillSettings}
  675. \Declaration
  676. Procedure GetFillSettings (Var FillInfo : FillSettingsType);
  677. \Description
  678. \var{GetFillSettings} returns the current fill-settings in
  679. \var{FillInfo}
  680. \Errors
  681. None.
  682. \SeeAlso
  683. \seep{SetFillPattern}
  684. \end{procedure}
  685. \begin{function}{GetGraphMode}
  686. \Declaration
  687. Function GetGraphMode : Integer;
  688. \Description
  689. \var{GetGraphMode} returns the current graphical mode. This value is
  690. entirely dependant on the hardware platform. To look up what this
  691. mode number represents from a capabilities standpoint, you should
  692. call either \var{QueryAdapterInfo} or \var{GetModeName} with the
  693. value returned by this function.
  694. \Errors
  695. None.
  696. \SeeAlso
  697. \seep{InitGraph}, \seep{QueryAdapterInfo}, \seep{GetModeName}
  698. \end{function}
  699. \begin{procedure}{GetImage}
  700. \Declaration
  701. Procedure GetImage (X1,Y1,X2,Y2 : Integer, Var Bitmap);
  702. \Description
  703. \var{GetImage}
  704. Places a copy of the screen area \var{(X1,Y1)} to \var{X2,Y2} in \var{BitMap}.
  705. \var{Bitmap} is an untyped parameter that must be equal to 12 plus the size
  706. of the screen area to save. The first two longints of \var{Bitmap} store
  707. the width and height of the region. The third longint is reserved and should
  708. not be modified.
  709. To make access to the screen faster, it is recommended that the starting
  710. points and ending point coordinates be modulo 4 and that the width to
  711. save be also modulo 4.
  712. To get the size of the bitmap required to save the area, you should call
  713. \var{ImageSize}.
  714. \Errors
  715. Bitmap must have enough room to contain the image.
  716. \SeeAlso
  717. \seef{ImageSize},
  718. \seep{PutImage}
  719. \end{procedure}
  720. \begin{procedure}{GetLineSettings}
  721. \Declaration
  722. Procedure GetLineSettings (Var LineInfo : LineSettingsType);
  723. \Description
  724. \var{GetLineSettings} returns the current Line settings in
  725. \var{LineInfo}
  726. \Errors
  727. None.
  728. \SeeAlso
  729. \seep{SetLineStyle}
  730. \end{procedure}
  731. \begin{function}{GetMaxColor}
  732. \Declaration
  733. Function GetMaxColor : Word;
  734. \Description
  735. \var{GetMaxColor} returns the maximum color-number which can
  736. be set with \var{SetColor}. This value is zero based, so a screen
  737. which supports 16 colors, would return 15.
  738. \Errors
  739. None.
  740. \SeeAlso
  741. \seep{SetColor},
  742. \seef{GetPaletteSize}
  743. \end{function}
  744. \begin{function}{GetMaxMode}
  745. \Declaration
  746. Function GetMaxMode : Word;
  747. \Description
  748. \var{GetMaxMode} returns the highest mode for the current driver. Normally
  749. the higher the mode number, the resolution it will be, but this might not
  750. always be the case.
  751. \Errors
  752. None.
  753. \SeeAlso
  754. \seep{InitGraph}
  755. \end{function}
  756. \begin{function}{GetMaxX}
  757. \Declaration
  758. Function GetMaxX : Word;
  759. \Description
  760. \var{GetMaxX} returns the maximum horizontal screen
  761. length (zero based from 0..\var{MaxX}).
  762. \Errors
  763. None.
  764. \SeeAlso
  765. \seef{GetMaxY}
  766. \end{function}
  767. \begin{function}{GetMaxY}
  768. \Declaration
  769. Function GetMaxY : Word;
  770. \Description
  771. \var{GetMaxY} returns the maximum number of screen
  772. lines. (zero based from 0..\var{MaxY}).
  773. \Errors
  774. None.
  775. \SeeAlso
  776. \seef{GetMaxY}
  777. \end{function}
  778. \begin{procedure}{GetModeRange}
  779. \Declaration
  780. Procedure GetModeRange (GraphDriver : Integer; var LoMode, HiMode: Integer);
  781. \Description
  782. \var{GetModeRange} returns the Lowest and Highest mode of the currently
  783. installed driver. If the value of \var{GraphDriver} is invalid, \var{LoMode}
  784. and var{HiMode} are set to -1.
  785. \Errors
  786. None.
  787. \SeeAlso
  788. \seep{InitGraph}, \seep{GetModeName}
  789. \end{procedure}
  790. \begin{function}{GetPaletteSize}
  791. \Declaration
  792. Function GetPaletteSize : Word;
  793. \Description
  794. \var{GetPaletteSize} returns the maximum number of entries which
  795. can be set in the current palette. In direct color mode, this simply
  796. returns the maximum possible of colors on screen.
  797. Usually this has the value \var{GetMaxColor} + 1.
  798. \Errors
  799. None.
  800. \SeeAlso
  801. \seep{GetPalette},
  802. \seep{SetPalette}
  803. \seep{GetMaxColor}
  804. \end{function}
  805. \begin{function}{GetPixel}
  806. \Declaration
  807. Function GetPixel (X,Y : Integer) : Word;
  808. \Description
  809. \var{GetPixel} returns the color
  810. of the point at \var{(X,Y)} The coordinates, as all coordinates
  811. are viewport relative.
  812. In direct color mode, the value returned is the direct RGB components of
  813. the color. In palette based modes, this indicates the palette entry number.
  814. \Errors
  815. None.
  816. \SeeAlso
  817. \end{function}
  818. \begin{procedure}{GetTextSettings}
  819. \Declaration
  820. Procedure GetTextSettings (Var TextInfo : TextSettingsType);
  821. \Description
  822. \var{GetTextSettings} returns the current text style settings : The font,
  823. direction, size and placement as set with \var{SetTextStyle} and
  824. \var{SetTextJustify}.
  825. \Errors
  826. None.
  827. \SeeAlso
  828. \seep{SetTextStyle}, \seep{SetTextJustify}
  829. \end{procedure}
  830. \begin{procedure}{GetViewSettings}
  831. \Declaration
  832. Procedure GetViewSettings (Var ViewPort : ViewPortType);
  833. \Description
  834. \var{GetViewSettings} returns the current view-port and clipping settings in
  835. \var{ViewPort}.
  836. \Errors
  837. None.
  838. \SeeAlso
  839. \seep{SetViewPort}
  840. \end{procedure}
  841. \begin{function}{GetX}
  842. \Declaration
  843. Function GetX : Integer;
  844. \Description
  845. \var{GetX} returns the X-coordinate of the current pointer. This value is
  846. viewport relative.
  847. \Errors
  848. None.
  849. \SeeAlso
  850. \seef{GetY}
  851. \end{function}
  852. \begin{function}{GetY}
  853. \Declaration
  854. Function GetY : Integer;
  855. \Description
  856. \var{GetY} returns the Y-coordinate of the current pointer. This value is
  857. viewport relative.
  858. \Errors
  859. None.
  860. \SeeAlso
  861. \seef{GetX}
  862. \end{function}
  863. \begin{procedure}{GraphDefaults}
  864. \Declaration
  865. Procedure GraphDefaults ;
  866. \Description
  867. \var{GraphDefaults} homes the current pointer, and resets the graphics
  868. system to the default values for:
  869. \begin{itemize}
  870. \item Active Line style is reset to normal width and filled line.
  871. \item The current fill color is set to the maximum palette color.
  872. \item The current fill style is set to \var{solidfill}.
  873. \item The user fill pattern is reset to \var{$FF}.
  874. \item The current drawing color is set to white.
  875. \item The current background color is reset to black.
  876. \item The viewport is reset to (0,0,\var{GetMaxX},\var{GetMaxY}).
  877. \item Clipping is enabled.
  878. \item The active write mode is set to normalput.
  879. \item Text settings are reset to : default font, \var{HorizDir},
  880. \var{LeftText} and \var{TopText}.
  881. \end{itemize}
  882. This routine is called by \var{SetGraphMode}.
  883. \Errors
  884. None.
  885. \SeeAlso
  886. \seep{SetViewPort}, \seep{SetFillStyle}, \seep{SetColor},
  887. \seep{SetBkColor}, \seep{SetLineStyle}, \seep{SetGraphMode}
  888. \end{procedure}
  889. \begin{function}{GraphErrorMsg}
  890. \Declaration
  891. Function GraphErrorMsg (ErrorCode : Integer) : String;
  892. \Description
  893. \var{GraphErrorMsg}
  894. returns a string describing the error \var{Errorcode}. This string can be
  895. used to let the user know what went wrong.
  896. \Errors
  897. None.
  898. \SeeAlso
  899. \seef{GraphResult}
  900. \end{function}
  901. \begin{function}{GraphResult}
  902. \Declaration
  903. Function GraphResult : Integer;
  904. \Description
  905. \var{GraphResult} returns an error-code for
  906. the last graphical operation. If the returned value is zero, all went well.
  907. A value different from zero means an error has occurred.
  908. Note that \var{GraphResult} is reset to zero after it has been called.
  909. Therefore the value should be saved into a temporary location if you wish
  910. to use it later.
  911. To see which routine might return errors, see the introduction section at
  912. the start of this reference.
  913. \Errors
  914. None.
  915. \SeeAlso
  916. \seef{GraphErrorMsg}
  917. \end{function}
  918. \begin{function}{ImageSize}
  919. \Declaration
  920. Function ImageSize (X1,Y1,X2,Y2 : Integer) : longint;
  921. \Description
  922. \var{ImageSize} returns the number of bytes needed to store the image
  923. by \var{GetImage} in the rectangle defined by \var{(X1,Y1)} and \var{(X2,Y2)}.
  924. The image size includes space for several words. The first three longints
  925. are reserved for use by \var{GetImage}, the first longint containing the
  926. width of the region, the second containing the height, and the third being
  927. reserved,the following words contains the bitmap itself.
  928. \textit{Compatibility:}
  929. The value returned by this function is a 32-bit value,
  930. and not a 16-bit value.
  931. \Errors
  932. None.
  933. \SeeAlso
  934. \seep{GetImage}
  935. \end{function}
  936. \begin{procedure}{InitGraph}
  937. \Declaration
  938. Procedure InitGraph (var GraphDriver,GraphModus : integer;\\
  939. const PathToDriver : string);
  940. \Description
  941. \var{InitGraph} initializes the \var{graph} package.
  942. \var{GraphDriver} has two valid values: \var{GraphDriver=Detect} which
  943. performs an auto detect and initializes the highest possible mode with the most
  944. colors. This is dependant on the platform, and many of the non-standard
  945. modes amy not be detected automatically. \var{graphMode} is the mode you
  946. wish to use.
  947. \var{PathToDriver} is only needed, if you use the BGI fonts from
  948. Borland, which are fully supported under FPC.
  949. The exact rundown of \var{InitGraph} is as follows: First it calls
  950. \var{QueryAdapterInfo} to get the possible modes supported by the hardware.
  951. It then saves the video state, initalizes some global variables, then if
  952. auto-detection was requested, calls \var{GetModeRange} to get the highest
  953. possible mode available and supported, otherwise it searches if the requested
  954. mode is available in the database. Finally , in either case it calls
  955. \var{SetGraphMode}.
  956. If the requested driver or mode is invalid, this function returns either
  957. \var{grError} or \var{grInvalidMode}.
  958. Before calling this function, you should call QueryAdapterInfo, and
  959. go through the list of supported modes to determine which mode suites
  960. your needs. As stated in the introduction, each graph unit implementation
  961. should support a 320x200 color mode.
  962. \Errors
  963. None.
  964. \SeeAlso
  965. Introduction, (page \pageref{se:Introduction}),
  966. \seep{DetectGraph}, \seep{CloseGraph}, \seef{GraphResult},
  967. \seef{QueryAdapterInfo}
  968. \end{procedure}
  969. Example:
  970. \begin{verbatim}
  971. var
  972. gd,gm : integer;
  973. PathToDriver : string;
  974. begin
  975. gd:=detect; { highest possible resolution }
  976. gm:=0; { not needed, auto detection }
  977. PathToDriver:='C:\PP\BGI'; { path to BGI fonts,
  978. drivers aren't needed }
  979. InitGraph(gd,gm,PathToDriver);
  980. if GraphResult<>grok then
  981. halt; ..... { whatever you need }
  982. CloseGraph; { restores the old graphics mode }
  983. end.
  984. \end{verbatim}
  985. \begin{function}{InstallUserDriver}
  986. \Declaration
  987. Function InstallUserDriver (DriverPath : String; AutoDetectPtr: Pointer) : Integer;
  988. \Description
  989. This routine is not supported in FPC, it is here only for compatiblity and
  990. always returns \var{grError}.
  991. \Errors
  992. None.
  993. \SeeAlso
  994. \seep{InitGraph}, \seef{InstallUserFont}
  995. \end{function}
  996. \begin{function}{InstallUserFont}
  997. \Declaration
  998. Function InstallUserFont (FontPath : String) : Integer;
  999. \Description
  1000. \var{InstallUserFont} adds the font in \var{FontPath} to the list of fonts
  1001. available to the text system. If the maximum number of allocated fonts has
  1002. been reached, this routine sets \var{GraphResult} to \var{grError}.
  1003. \Errors
  1004. None.
  1005. \SeeAlso
  1006. \seep{InitGraph}, \seef{InstallUserDriver}
  1007. \end{function}
  1008. \begin{procedure}{Line}
  1009. \Declaration
  1010. Procedure Line (X1,Y1,X2,Y2 : Integer);
  1011. \Description
  1012. \var{Line} draws a line starting from
  1013. \var{(X1,Y1} to \var{(X2,Y2)}, in the current line style and color.
  1014. The current pointer is not updated after this call.
  1015. This is the base routine which is called by several other routines
  1016. in this unit. This routine is somewhat faster then the other
  1017. LineXXX routines contained herein.
  1018. \Errors
  1019. None.
  1020. \SeeAlso
  1021. \seep{LineRel},\seep{LineTo}
  1022. \end{procedure}
  1023. \begin{procedure}{LineRel}
  1024. \Declaration
  1025. Procedure LineRel (DX,DY : Integer);
  1026. \Description
  1027. \var{LineRel} draws a line starting from
  1028. the current pointer position to the point\var{(DX,DY}, \textbf{relative} to the
  1029. current position, in the current line style and color. The Current Position
  1030. is set to the endpoint of the line.
  1031. \Errors
  1032. None.
  1033. \SeeAlso
  1034. \seep{Line}, \seep{LineTo}
  1035. \end{procedure}
  1036. \begin{procedure}{LineTo}
  1037. \Declaration
  1038. Procedure LineTo (DX,DY : Integer);
  1039. \Description
  1040. \var{LineTo} draws a line starting from
  1041. the current pointer position to the point\var{(DX,DY}, \textbf{relative} to the
  1042. current position, in the current line style and color. The Current position
  1043. is set to the end of the line.
  1044. \Errors
  1045. None.
  1046. \SeeAlso
  1047. \seep{LineRel},\seep{Line}
  1048. \end{procedure}
  1049. \begin{procedure}{MoveRel}
  1050. \Declaration
  1051. Procedure MoveRel (DX,DY : Integer;
  1052. \Description
  1053. \var{MoveRel} moves the current pointer to the
  1054. point \var{(DX,DY)}, relative to the current pointer
  1055. position
  1056. \Errors
  1057. None.
  1058. \SeeAlso
  1059. \seep{MoveTo}
  1060. \end{procedure}
  1061. \begin{procedure}{MoveTo}
  1062. \Declaration
  1063. Procedure MoveTo (X,Y : Integer);
  1064. \Description
  1065. \var{MoveTo} moves the current pointer to the
  1066. point \var{(X,Y)}.
  1067. \Errors
  1068. None.
  1069. \SeeAlso
  1070. \seep{MoveRel}
  1071. \end{procedure}
  1072. \begin{procedure}{OutText}
  1073. \Declaration
  1074. Procedure OutText (Const TextString : String);
  1075. \Description
  1076. \var{OutText} puts \var{TextString} on the screen, at the current pointer
  1077. position, using the current font and text settings. The current pointer is
  1078. updated only if the text justification is set to left and is horizontal.
  1079. The text is truncated according to the current viewport settings if it
  1080. cannot fit.
  1081. In order to maintain compatibility when using several fonts, use \var{TextWidth}
  1082. and \var{TextHeight} calls to determine the dimensions of the string.
  1083. \Errors
  1084. None.
  1085. \SeeAlso
  1086. \seep{OutTextXY}
  1087. \end{procedure}
  1088. \begin{procedure}{OutTextXY}
  1089. \Declaration
  1090. Procedure OutTextXY (X,Y : Integer; Const TextString : String);
  1091. \Description
  1092. \var{OutText} puts \var{TextString} on the screen, at position \var{(X,Y)},
  1093. using the current font and text settings.
  1094. Contrary to \var{OutText} , this routine does not update the current pointer.
  1095. In order to maintain compatibility when using several fonts, use \var{TextWidth}
  1096. and \var{TextHeight} calls to determine the dimensions of the string.
  1097. \Errors
  1098. None.
  1099. \SeeAlso
  1100. \seep{OutText}
  1101. \end{procedure}
  1102. \begin{procedure}{PieSlice}
  1103. \Declaration
  1104. Procedure PieSlice (X,Y,stangle,endAngle:integer;Radius: Word);
  1105. \Description
  1106. \var{PieSlice}
  1107. draws and fills a sector of a circle with center \var{(X,Y)} and radius
  1108. \var{Radius}, starting at angle \var{StAngle} and ending at angle \var{EndAngle}
  1109. using the current fill style and fill pattern. The pie slice is outlined
  1110. with the current line style and current active color.
  1111. \Errors
  1112. None.
  1113. \SeeAlso
  1114. \seep{Arc}, \seep{Circle}, \seep{Sector}
  1115. \end{procedure}
  1116. \begin{procedure}{PutImage}
  1117. \Declaration
  1118. Procedure PutImage (X,Y: Integer; var Bitmap; BitBlt: Word);
  1119. \Description
  1120. \var{PutImage}
  1121. Places the bitmap in \var{Bitmap} on the screen at upper left
  1122. corner \var{(X, Y)}. \var{BitBlt} determines how the bitmap
  1123. will be placed on the screen. Possible values are :
  1124. \begin{itemize}
  1125. \item CopyPut
  1126. \item XORPut
  1127. \item ORPut
  1128. \item AndPut
  1129. \item NotPut
  1130. \end{itemize}
  1131. \textit{Compatibility}
  1132. Contrary to the Borland graph unit, putimage \textit{is} clipped to the
  1133. viewport boundaries.
  1134. \Errors
  1135. None
  1136. \SeeAlso
  1137. \seef{ImageSize},\seep{GetImage}
  1138. \end{procedure}
  1139. \begin{procedure}{PutPixel}
  1140. \Declaration
  1141. Procedure PutPixel (X,Y : Integer; Color : Word);
  1142. \Description
  1143. Puts a point at
  1144. \var{(X,Y)} using color \var{Color}. This routine is viewport
  1145. relative.
  1146. \Errors
  1147. None.
  1148. \SeeAlso
  1149. \seef{GetPixel}
  1150. \end{procedure}
  1151. \begin{procedure}{Rectangle}
  1152. \Declaration
  1153. Procedure Rectangle (X1,Y1,X2,Y2 : Integer);
  1154. \Description
  1155. Draws a rectangle with
  1156. corners at \var{(X1,Y1)} and \var{(X2,Y2)}, using the current color and
  1157. the current line style.
  1158. \Errors
  1159. None.
  1160. \SeeAlso
  1161. \seep{Bar}, \seep{Bar3D}
  1162. \end{procedure}
  1163. \begin{function}{RegisterBGIDriver}
  1164. \Declaration
  1165. Function RegisterBGIDriver (Driver : Pointer) : Integer;
  1166. \Description
  1167. This routine is not supported in FPC. It is here for compatibility and it
  1168. always returns \var{grError}.
  1169. \Errors
  1170. None.
  1171. \SeeAlso
  1172. \seef{InstallUserDriver},
  1173. \seef{RegisterBGIFont}
  1174. \end{function}
  1175. \begin{function}{RegisterBGIFont}
  1176. \Declaration
  1177. Function RegisterBGIFont (Font : Pointer) : Integer;
  1178. \Description
  1179. This routine permits the user to add a font to the list of known fonts
  1180. by the graph unit. \var{Font} is a pointer to image of the loaded font.
  1181. The value returned is either a negative error number (\var{grInvalidFont}),
  1182. or the font number you need to use when accessing it via \var{SetTextStyle}.
  1183. This routine may be called before \var{InitGraph}.
  1184. \textit{Compatibility}
  1185. Watch out for the byte endian when using this routine. This might work
  1186. on little endian machines, and not on big endian machines and vice-versa.
  1187. \Errors
  1188. None.
  1189. \SeeAlso
  1190. \seef{InstallUserFont},
  1191. \seef{RegisterBGIDriver}
  1192. \end{function}
  1193. \begin{procedure}{RestoreCRTMode}
  1194. \Declaration
  1195. Procedure RestoreCRTMode ;
  1196. \Description
  1197. Restores the screen mode which was active before
  1198. the graphical mode was started. Can be used to switch back and forth
  1199. between text and graphics mode.
  1200. \Errors
  1201. None.
  1202. \SeeAlso
  1203. \seep{InitGraph}
  1204. \end{procedure}
  1205. Example:
  1206. \begin{verbatim}
  1207. uses Graph;
  1208. var
  1209. Gd, Gm: Integer;
  1210. Mode: Integer;
  1211. begin
  1212. Gd := Detect;
  1213. InitGraph(Gd, Gm, ' ');
  1214. if GraphResult <> grOk then
  1215. Halt(1);
  1216. OutText('<ENTER> to leave graphics:');
  1217. Readln;
  1218. RestoreCrtMode;
  1219. Writeln('Now in text mode');
  1220. Write('<ENTER> to enter graphics mode:');
  1221. Readln;
  1222. SetGraphMode(GetGraphMode);
  1223. OutTextXY(0, 0, 'Back in graphics mode');
  1224. OutTextXY(0, TextHeight('H'), '<ENTER> to quit:');
  1225. Readln;
  1226. CloseGraph;
  1227. end.
  1228. \end{verbatim}
  1229. \begin{procedure}{Sector}
  1230. \Declaration
  1231. Procedure Sector (X,Y : Integer; StAngle,EndAngle,XRadius,YRadius : Word);
  1232. \Description
  1233. \var{Sector}
  1234. draws and fills a sector of an ellipse with center \var{(X,Y)} and radii
  1235. \var{XRadius} and \var{YRadius}, starting at angle \var{StAngle} and ending at angle
  1236. \var{EndAngle}. The sector is outlined in the current color and filled with
  1237. the pattern and color defined by \var{SetFillStyle} or \var{SetFillPattern}.
  1238. \Errors
  1239. None.
  1240. \SeeAlso
  1241. \seep{Arc}, \seep{Circle}, \seep{PieSlice}
  1242. \end{procedure}
  1243. \begin{procedure}{SetActivePage}
  1244. \Declaration
  1245. Procedure SetActivePage (Page : Word);
  1246. \Description
  1247. Sets \var{Page} as the active page
  1248. for all graphical output. This means that all drawing will be done on this
  1249. graphics, be it visible or not.
  1250. The usual way to make fast animation, is to draw to a non visible active page
  1251. and the simply call make that active page the visible page by calling
  1252. \var{SetVisualPage}.
  1253. \textit{Compatibility}:
  1254. Not all systems and graphics mode support multiple graphics pages, to
  1255. determine how many pages are available see \var{QueryAdapterInfo}.
  1256. Multiple pages are currently not supported with DOS VESA modes.
  1257. \Errors
  1258. None.
  1259. \SeeAlso
  1260. \seep{SetVisualPage}, \seep{QueryAdapterInfo}
  1261. \end{procedure}
  1262. \begin{procedure}{SetAllPallette}
  1263. \Declaration
  1264. Procedure SetAllPallette (Var Palette);
  1265. \Description
  1266. Sets the current palette to
  1267. \var{Palette}. \var{Palette} is an untyped variable, usually pointing to a
  1268. record of type \var{PaletteType} which contains the Red, Green and Blue
  1269. components of the RGB components to change for each color entry. If
  1270. the Red, Green and Blue components are equal to -1 for a specific color
  1271. entry, then that palette entry will not be changed. The size should
  1272. contain the size of the palette to change (indexed at zero).
  1273. \textit{Compatibility}:
  1274. This call is not the same as in Turbo Pascal. RGB components should be
  1275. set in LSB if each of the components has less then 16-bits resolution.
  1276. This call is not supported in direct color modes.
  1277. \Errors
  1278. None.
  1279. \SeeAlso
  1280. \seep{GetPalette}
  1281. \end{procedure}
  1282. \begin{procedure}{SetAspectRatio}
  1283. \Declaration
  1284. Procedure SetAspectRatio (Xasp,Yasp : Word);
  1285. \Description
  1286. Sets the aspect ratio of the
  1287. current screen to \var{Xasp/Yasp}. The value of the aspect ratio is used
  1288. by certain routines herein to draw circles which will actually appear round
  1289. depending on the screen mode.
  1290. \Errors
  1291. None
  1292. \SeeAlso
  1293. \seep{InitGraph}, \seep{GetAspectRatio}
  1294. \end{procedure}
  1295. \begin{procedure}{SetBkColor}
  1296. \Declaration
  1297. Procedure SetBkColor (Color : Word);
  1298. \Description
  1299. Sets the background color to
  1300. \var{Color}.
  1301. The behaviour of this routine depends if we are in a direct color
  1302. mode or not. In direct color mode, this value represents the direct
  1303. RGB values to plot to the screen. In non direct color mode, the value
  1304. represents an index to the color palette entry on the hardware.
  1305. \Errors
  1306. None.
  1307. \SeeAlso
  1308. \seef{GetBkColor}, \seep{SetColor}
  1309. \end{procedure}
  1310. \begin{procedure}{SetColor}
  1311. \Declaration
  1312. Procedure SetColor (Color : Word);
  1313. \Description
  1314. Sets the foreground color to
  1315. \var{Color}.
  1316. The behaviour of this routine depends if we are in a direct color
  1317. mode or not. In direct color mode, this value represents the direct
  1318. RGB values to plot to the screen. In non direct color mode, the value
  1319. represents an index to the color palette entry on the hardware.
  1320. \Errors
  1321. None.
  1322. \SeeAlso
  1323. \seef{GetColor}, \seep{SetBkColor}
  1324. \end{procedure}
  1325. \begin{procedure}{SetFillPattern}
  1326. \Declaration
  1327. Procedure SetFillPattern (Pattern : FillPatternType, Color : Word);
  1328. \Description
  1329. \var{SetFillPattern} sets the current fill-pattern to \var{Pattern}, and
  1330. the filling color to \var{Color}. If invalid input is passed to
  1331. \var{SetFillPattern}, \var{GraphResult} will return \var{grError}.
  1332. The pattern is an 8x8 raster, corresponding to the 64 bits in
  1333. \var{FillPattern}. Whenever a bit in a pattern byte is valued at 1,
  1334. a pixel will be plotted. The pattern and color is used by \var{Bar},
  1335. \var{FillPoly}, \var{FloodFill}, \var{bar3d}, \var{FillEllipse},
  1336. \var{Sector}, and \var{PieSlice}.
  1337. \Errors
  1338. None
  1339. \SeeAlso
  1340. \seep{GetFillPattern}, \seep{SetFillStyle}
  1341. \end{procedure}
  1342. \begin{procedure}{SetFillStyle}
  1343. \Declaration
  1344. Procedure SetFillStyle (Pattern, Color : word);
  1345. \Description
  1346. \var{SetFillStyle} sets the filling pattern and color to one of the
  1347. predefined filling patterns. \var{Pattern} can be one of the following predefined
  1348. constants :
  1349. \begin{itemize}
  1350. \item \var{EmptyFill } Uses backgroundcolor.
  1351. \item \var{SolidFill } Uses filling color
  1352. \item \var{LineFill } Fills with horizontal lines.
  1353. \item \var{ltSlashFill} Fills with lines from left-under to top-right.
  1354. \item \var{SlashFill } Idem as previous, thick lines.
  1355. \item \var{BkSlashFill} Fills with thick lines from left-Top to bottom-right.
  1356. \item \var{LtBkSlashFill} Idem as previous, normal lines.
  1357. \item \var{HatchFill} Fills with a hatch-like pattern.
  1358. \item \var{XHatchFill} Fills with a hatch pattern, rotated 45 degrees.
  1359. \item \var{InterLeaveFill}
  1360. \item \var{WideDotFill} Fills with dots, wide spacing.
  1361. \item \var{CloseDotFill} Fills with dots, narrow spacing.
  1362. \item \var{UserFill} Fills with a user-defined pattern.
  1363. \end{itemize}
  1364. If invalid input is passed to \var{SetFillStyle},
  1365. \var{GraphResult} will return \var{grError}.
  1366. \Errors
  1367. None.
  1368. \SeeAlso
  1369. \seep{SetFillPattern}
  1370. \end{procedure}
  1371. \begin{procedure}{SetGraphBufSize}
  1372. \Declaration
  1373. Procedure SetGraphBufSize (BufSize : Word);
  1374. \Description
  1375. This routine does nothing in FPC, and is here for compatibility.
  1376. \Errors
  1377. None.
  1378. \SeeAlso
  1379. \end{procedure}
  1380. \begin{procedure}{SetGraphMode}
  1381. \Declaration
  1382. Procedure SetGraphMode (Mode : Integer);
  1383. \Description
  1384. \var{SetGraphMode} sets the
  1385. graphical mode and clears the screen. \var{Mode} must be a valid mode,
  1386. which can be queried by \var{QueryAdapterInfo}.
  1387. If invalid input is passed to \var{SetGraphMode}, or if the mode cannot
  1388. be set for a reason, \var{GraphResult} returns \var{grInvalidMode}.
  1389. \var{SetGraphMode} resets all graphics variables to their default
  1390. settings (such as if \var{GraphDefaults} was called, the active page
  1391. is reset to page zero, the visual page is reset to page zero, and the viewport
  1392. is set to the entire screen.
  1393. \Errors
  1394. None.
  1395. \SeeAlso
  1396. \seep{InitGraph}, \seep{QueryAdapterInfo}
  1397. \end{procedure}
  1398. \begin{procedure}{SetLineStyle}
  1399. \Declaration
  1400. Procedure SetLineStyle (LineStyle, Pattern, Thickness : Word);
  1401. \Description
  1402. \var{SetLineStyle}
  1403. sets the drawing style for lines. You can specify a \var{LineStyle} which is
  1404. one of the following pre-defined constants:
  1405. \begin{itemize}
  1406. \item \var{Solidln=0;} draws a solid line.
  1407. \item \var{Dottedln=1;} Draws a dotted line.
  1408. \item \var{Centerln=2;} draws a non-broken centered line.
  1409. \item \var{Dashedln=3;} draws a dashed line.
  1410. \item \var{UserBitln=4;} Draws a User-defined bit pattern.
  1411. \end{itemize}
  1412. If \var{UserBitln} is specified then \var{Pattern} contains the bit pattern to
  1413. use for drawing the line. A bit of 1 specified a pixel which is on.
  1414. In all another cases, \var{Pattern} is ignored. The parameter \var{Thickness}
  1415. indicates how thick the line should be. You can specify one of the following
  1416. pre-defined constants:
  1417. \begin{itemize}
  1418. \item \var{NormWidth=1}
  1419. \item \var{ThickWidth=3}
  1420. \end{itemize}
  1421. If invalid input is passed to \var{SetLineStyle} , \var{GraphResult} will
  1422. return \var{grError}.
  1423. \Errors
  1424. None.
  1425. \SeeAlso
  1426. \seep{GetLineSettings}
  1427. \end{procedure}
  1428. \begin{procedure}{SetPalette}
  1429. \Declaration
  1430. Procedure SetPalette (ColorNum : Word; Color : Shortint);
  1431. \Description
  1432. \var{SetPalette} changes the \var{ColorNum}-th entry in the palette to
  1433. \var{Color}. For examples, \var{SetPalette(0, LightCyan)} makes the first
  1434. color in the palette light cyan. \var{Color} only accepts certain default
  1435. colors, as specified in the \var{Color constants} section. If invalid
  1436. input is passed to \var{SetPalette}, \var{GraphResult} returns a value
  1437. of \var{grError} and the palette remains intact.
  1438. Changes made to the palette are immediately visible on the screen.
  1439. This routine returns \var{grError} if called in a direct color mode.
  1440. \Errors
  1441. None.
  1442. \SeeAlso
  1443. \seep{SetAllPallette},\seep{SetRGBPalette}
  1444. \end{procedure}
  1445. \begin{procedure}{SetRGBPalette}
  1446. \Declaration
  1447. Procedure SetRGBPalette (ColorNum,Red,Green,Blue : Integer);
  1448. \Description
  1449. \var{SetRGBPalette} sets the \var{ColorNum}-th entry in the palette to the
  1450. color with RGB values \var{Red, Green Blue}. The Red , Green and Blue values
  1451. must be in LSB format. If the palette entry could not be changed for a
  1452. reason, the routine returns \var{grError}.
  1453. This routine returns \var{grError} if called in a direct color mode.
  1454. \Errors
  1455. None.
  1456. \SeeAlso
  1457. \seep{SetAllPallette},
  1458. \seep{SetPalette}
  1459. \seep{GetRGBPalette}
  1460. \end{procedure}
  1461. \begin{procedure}{SetTextJustify}
  1462. \Declaration
  1463. Procedure SetTextJustify (Horiz, Vert : Word);
  1464. \Description
  1465. \var{SetTextJustify} controls the placement of new text, relative to the
  1466. (graphical) cursor position. \var{Horiz} controls horizontal placement, and can be
  1467. one of the following pre-defined constants:
  1468. \begin{itemize}
  1469. \item \var{LeftText=0;} Text is set left of the current pointer.
  1470. \item \var{CenterText=1;} Text is set centered horizontally on the current pointer.
  1471. \item \var{RightText=2;} Text is set to the right of the current pointer.
  1472. \end{itemize}
  1473. \var{Vertical} controls the vertical placement of the text, relative to the
  1474. (graphical) cursor position. Its value can be one of the following
  1475. pre-defined constants :
  1476. \begin{itemize}
  1477. \item \var{BottomText=0;} Text is placed under the current pointer.
  1478. \item \var{CenterText=1;} Text is placed centered vertically on the current pointer.
  1479. \item \var{TopText=2;}Text is placed above the current pointer.
  1480. \end{itemize}
  1481. If invalid input is passed \var{SetTextJustify} , \var{GraphResult} returns
  1482. \var{grError}.
  1483. \Errors
  1484. None.
  1485. \SeeAlso
  1486. \seep{OutText}, \seep{OutTextXY}
  1487. \end{procedure}
  1488. \begin{procedure}{SetTextStyle}
  1489. \Declaration
  1490. Procedure SetTextStyle (Font,Direction,Magnitude : Word);
  1491. \Description
  1492. \var{SetTextStyle} controls the style of text to be put on the screen.
  1493. pre-defined constants for \var{Font} are:
  1494. \begin{itemize}
  1495. \item \var{DefaultFont=0;}
  1496. \item \var{TriplexFont=2;}
  1497. \item \var{SmallFont=2;}
  1498. \item \var{SansSerifFont=3;}
  1499. \item \var{GothicFont=4;}
  1500. \end{itemize}
  1501. Pre-defined constants for \var{Direction} are :
  1502. \begin{itemize}
  1503. \item \var{HorizDir=0;}
  1504. \item \var{VertDir=1;}
  1505. \end{itemize}
  1506. Charsize indicated the magnification factor to use when drawing the fonts
  1507. to the screen. When using the default internal font, this value can be
  1508. any value equal or greater to one. In the case of stroked fonts, the
  1509. value should always be equal or greater then 4.
  1510. Stroked fonts are usually loaded from disk once onto the heap when a call
  1511. is made to \var{SetTextStyle}.
  1512. If there is an error when using this routine, \var{GraphResult} might return
  1513. \var{grFontNotFound}, \var{grNoFontMem}, \var{grError}, \var{grIoError},
  1514. \var{grInvalidFont}, or \var{grInvalidFontNum}.
  1515. \Errors
  1516. None.
  1517. \SeeAlso
  1518. \seep{GetTextSettings}
  1519. \end{procedure}
  1520. \begin{procedure}{SetUserCharSize}
  1521. \Declaration
  1522. Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
  1523. \Description
  1524. Sets the width and height of vector-fonts. The horizontal size is given
  1525. by \var{Xasp1/Xasp2}, and the vertical size by \var{Yasp1/Yasp2}.
  1526. \Errors
  1527. None.
  1528. \SeeAlso
  1529. \seep{SetTextStyle}
  1530. \end{procedure}
  1531. \begin{procedure}{SetViewPort}
  1532. \Declaration
  1533. Procedure SetViewPort (X1,Y1,X2,Y2 : Integer; Clip : Boolean);
  1534. \Description
  1535. Sets the current graphical view-port (window) to the rectangle defined by
  1536. the top-left corner \var{(X1,Y1)} and the bottom-right corner \var{(X2,Y2)}.
  1537. If \var{Clip} is true, anything drawn outside the view-port (window) will be
  1538. clipped (i.e. not drawn). Coordinates specified after this call are relative
  1539. to the top-left corner of the view-port.
  1540. \Errors
  1541. None.
  1542. \SeeAlso
  1543. \seep{GetViewSettings}
  1544. \end{procedure}
  1545. \begin{procedure}{SetVisualPage}
  1546. \Declaration
  1547. Procedure SetVisualPage (Page : Word);
  1548. \Description
  1549. \var{SetVisualPage} sets the video page to page number \var{Page}.
  1550. \Errors
  1551. None
  1552. \SeeAlso
  1553. \seep{SetActivePage}
  1554. \end{procedure}
  1555. \begin{procedure}{SetWriteMode}
  1556. \Declaration
  1557. Procedure SetWriteMode (Mode : Integer);
  1558. \Description
  1559. \var{SetWriteMode} controls the drawing of lines on the screen. It controls
  1560. the binary operation used when drawing lines on the screen. \var{Mode} can
  1561. be one of the following pre-defined constants:
  1562. \begin{itemize}
  1563. \item CopyPut=0;
  1564. \item XORPut=1;
  1565. \end{itemize}
  1566. \Errors
  1567. None.
  1568. \SeeAlso
  1569. \end{procedure}
  1570. \begin{function}{TextHeight}
  1571. \Declaration
  1572. Function TextHeight (S : String) : Word;
  1573. \Description
  1574. \var{TextHeight} returns the height (in pixels) of the string \var{S} in
  1575. the current font and text-size.
  1576. \Errors
  1577. None.
  1578. \SeeAlso
  1579. \seef{TextWidth}
  1580. \end{function}
  1581. \begin{function}{TextWidth}
  1582. \Declaration
  1583. Function TextWidth (S : String) : Word;
  1584. \Description
  1585. \var{TextHeight} returns the width (in pixels) of the string \var{S} in
  1586. the current font and text-size.
  1587. \Errors
  1588. None.
  1589. \SeeAlso
  1590. \seef{TextHeight}
  1591. \end{function}