Sign in Join
FPDoc Onlineexperiment

Graph unit

TP compatible unit to handle screen graphics.

This document describes the GRAPH unit for Free Pascal, for all platforms. The unit was first written for dos by Florian Klaempfl, but was later completely rewritten by Carl-Eric Codere to be completely portable. The unit is provided for compatibility only: It is recommended to use more modern graphical systems. The graph unit will allow to recompile old programs. They will work to some extent, but if the application has heavy graphical needs, it's recommended to use another set of graphical routines, suited to the platform the program should work on.

Classes and records

ArcCoordsTyperecordDescribe the last arc which was drawn on screen.
FillSettingsTyperecordRecord describing fill mode.
LineSettingsTyperecordRecord describing current line drawing mode.
PaletteTyperecordRecord describing palette.
PointTyperecordRecord describing a point in a 2 dimensional plane.
RGBRecrecordRecord describing palette RGB color.
TextSettingsTyperecordRecord describing how texts are drawn.
TModeInforecordRecord describing a graphical mode.
TResolutionRecrecordRecord describing resolution.
ViewPortTyperecordRecord describing a viewport.

Procedures and functions

ArcprocedureDraw part of a circle.
BarprocedureDraw filled rectangle.
Bar3DprocedureDraw filled 3-dimensional rectangle.
ClearDeviceprocedureClear the complete screen.
ClosegraphprocedureClose graphical system.
DetectGraphprocedureDetect correct graphical driver to use.
DrawPolyprocedureDraw a polygon.
EllipseprocedureDraw an ellipse.
FillEllipseprocedureDraw and fill an ellipse.
FillPolyprocedureDraw, close and fill a polygon.
FloodFillprocedureFill an area with a given color.
GetArcCoordsprocedureReturn coordinates of last drawn arc or ellipse.
GetAspectRatioprocedureReturn screen resolution.
GetColorfunctionReturn current drawing color.
GetDefaultPaletteprocedureReturn default palette.
GetDirectVideofunctionDetermine whether direct video mode is active.
GetDriverNamefunctionReturn current driver name.
GetFillPatternprocedureReturn current fill pattern.
GetFillSettingsprocedureReturn current fill settings.
GetGraphModefunctionGet current graphical modus.
GetLineSettingsprocedureGet current line drawing settings.
GetMaxColorfunctionreturn maximum number of colors.
GetMaxModefunctionReturn biggest mode for the current driver.
GetMaxXfunctionReturn maximal X coordinate.
GetMaxYfunctionReturn maximal Y coordinate.
GetModeNamefunctionReturn description a modus.
GetModeRangeprocedureReturn lowest and highest modus of current driver.
GetPaletteprocedureReturn current palette.
GetPaletteSizefunctionReturn maximal number of entries in current palette.
GetTextSettingsprocedureReturn current text style.
GetViewSettingsprocedureReturn current viewport.
GetXfunctionReturn current cursor X position.
GetYfunctionReturn current cursor Y position.
GraphDefaultsprocedureReset graphical mode to defaults.
GraphErrorMsgfunctionReturn a description of an error.
GraphResultfunctionResult of last graphical operation.
InitGraphprocedureInitialize graphical system.
InstallUserDriverfunctionInstall a user driver.
InstallUserFontfunctionInstall a user-defined font.
LineRelprocedureDraw a line starting from current position in given direction.
LineToprocedureDraw a line starting from current position to a given point.
MoveRelprocedureMove cursor relative to current position.
MoveToprocedureMove cursor to absolute position.
OutTextprocedureWrite text on the screen at the current location.
PieSliceprocedureDraw a pie-slice.
queryadapterinfofunctionFunction called to retrieve the current video adapter settings.
RectangleprocedureDraw a rectangle on the screen.
RegisterBGIDriverfunctionRegister a new BGI driver.
RegisterBGIfontfunctionRegister a new BGI font.
RestoreCrtModeprocedureRestore text screen.
SectorprocedureDraw and fill a sector of an ellipse.
SetAspectRatioprocedureSet aspect ration of the screen.
SetColorprocedureSet foreground drawing color.
SetDirectVideoprocedureAttempt to enter direct video mode.
SetFillPatternprocedureSet drawing fill pattern.
SetFillStyleprocedureSet drawing fill style.
SetGraphModeprocedureSet graphical mode.
SetLineStyleprocedureSet line drawing style.
SetPaletteprocedureSet palette entry using color constant.
SetTextJustifyprocedureSet text placement style.
SetTextStyleprocedureSet text style.
SetUserCharSizeprocedureSet user character size for vector font.
SetViewPortprocedureSet the graphical drawing window.
SetWriteModeprocedureSpecify binary operation to perform when drawing on screen.
SetWriteModeExprocedureSet write mode (extended version).
TextHeightfunctionReturn height (in pixels) of the given string.
TextWidthfunctionReturn width (in pixels) of the given string.

Types

CircleProcprocedure typeStandard circle drawing routine prototype.
clrviewprocprocedure typeStandard clearviewport routine prototype.
ColorTypetypeColor type alias.
defpixelprocprocedure typeStandard pixel drawing routine prototype.
ellipseprocprocedure typeStandard ellipse drawing routine prototype.
FillPatternTypetypeBit pattern used when drawing lines. Set bits are drawn.
GetBkColorProcprocedure typeGetBKColor callback prototype.
getimageprocprocedure typeStandard procedure prototype.
getpixelprocprocedure typeStandard pixel fetching routine prototype.
getrgbpaletteprocprocedure typeThis routine prototype is a hook for .
getscanlineprocprocedure typeStandard getscanline routine prototype.
graph_floattypeThe platform's preferred floating point size for fast graph operations.
graphfreememprcprocedure typeProcedure prototype, used when heap memory is freed by the graph routines.
graphgetmemprcprocedure typeProcedure prototype, used when heap memory is needed by the graph routines.
hlineprocprocedure typeStandard procedure prototype to draw a single horizontal line.
imagesizeprocprocedure typeStandard calculation procedure prototype.
initmodeprocprocedure typeStandard routine prototype to initialize a mode.
lineprocprocedure typeStandard line drawing routine prototype.
OutTextXYProcprocedure typeThis routine prototype is a hook for .
patternlineprocprocedure typeStandard procedure prototype to draw a patterned line.
PCharsetTransTabletypePointer to array.
PModeInfotypePointer to record.
putimageprocprocedure typeStandard procedure prototype.
putpixelprocprocedure typeStandard pixel drawing routine prototype.
restorestateprocprocedure typeStandard routine prototype to restore the graphical state at a closegraph call.
savestateprocprocedure typeStandard routine prototype to save the graphical state before a mode is set.
setactivepageprocprocedure typeStandard procedure prototype.
SetAllPaletteProcprocedure typeThis routine prototype is a hook for .
SetBkColorProcprocedure typeSetBKColor callback prototype.
setrgbpaletteprocprocedure typeThis routine prototype is a hook for .
setvisualpageprocprocedure typeStandard procedure prototype.
TCharsetTransTabletypeCharacter transliteration table, with entries for 256 characters.
vlineprocprocedure typeStandard procedure prototype to draw a single vertical line.

Constants

AndPutconstantDraw operation: use AND.
AnsiToASCIITransTableconstantDefault ansi transliteration table.
BkSlashFillconstantFill style: Diagonal (backslash) lines.
blackconstantColor code: black.
blueconstantColor code: blue.
BoldFontconstantFont number: Bold font.
BottomTextconstantVertical text alignment: Align text to bottom.
brownconstantColor code: brown.
CenterLnconstantLine style: centered line.
CenterTextconstantHorizontal text alignment: Center text.
CGAconstantGraphic driver for CGA cards.
CGAC0constantCGA Graphic driver mode C0.
CGAC1constantCGA Graphic driver mode C1.
CGAC2constantCGA Graphic driver mode C2.
CGAC3constantCGA Graphic driver mode C3.
CGAHiconstantCGA Graphic driver Hi-res mode.
ClipOffconstantViewport clipping off.
ClipOnconstantViewport clipping on.
CloseDotFillconstantFill style: Closely spaced dotted lines.
CopyPutconstantDraw operation: use Copy.
CurrentDriverconstantCurrently used driver.
cyanconstantColor code: Cyan.
D12bitconstantMode: Depth 12 bit.
D15bitconstantMode: Depth 15 bit.
D16bitconstantMode: Depth 16 bit.
D1bitconstantMode: Depth 1 bit.
D24bitconstantMode: Depth 24 bit.
D2bitconstantMode: Depth 2 bit.
D32bitconstantMode: Depth 32 bit.
D4bitconstantMode: Depth 4 bit.
D64bitconstantMode: Depth 64 bit.
D6bitconstantMode: Depth 6 bit.
D8bitconstantMode: Depth 8 bit.
darkgrayconstantColor code: Dark gray.
DashedLnconstantLine style: dashed line.
DefaultconstantDefault mode.
DefaultFontconstantFont number: Normal font.
DetectconstantMode: Detect mode.
detectModeconstantMode: Autodetect optimal mode.
DottedLnconstantLine style: Dotted line.
DrawTextBackgroundconstantShould the background of texts be drawn or should it be left untouched ?
EGAconstantGraphic driver for EGA cards.
EGA64constantGraphic driver for EGA 64 cards.
EGA64HiconstantEGA64 graphic driver high resolution mode.
EGA64LoconstantEGA64 graphic driver low resolution mode.
EGABlackconstantColor code: EGA Black.
EGABlueconstantColor code: EGA blue.
EGABrownconstantColor code: EGA brown.
EGACyanconstantColor code: EGA cyan.
EGADarkgrayconstantColor code: EGA dark gray.
EGAGreenconstantColor code: EGA green.
EGAHiconstantEGA graphic driver high resolution mode.
EGALightblueconstantColor code: EGA Light blue.
EGALightcyanconstantColor code: EGA Light cyan.
EGALightgrayconstantColor code: EGA Light gray.
EGALightgreenconstantColor code: EGA Light green.
EGALightmagentaconstantColor code: EGA light magenta.
EGALightredconstantColor code: EGA light red.
EGALoconstantEGA graphic driver low resolution mode.
EGAMagentaconstantColor code: EGA magenta.
EGAMonoconstantGraphic driver for EGA monochrome cards.
EGAMonoHiconstantEGAMono graphic driver high resolution mode.
EGARedconstantColor code: EGA red.
EGAWhiteconstantColor code: EGA white.
EGAYellowconstantColor code: EGA yellow.
EmptyFillconstantFill style: Do not fill.
EuroFontconstantFont number: ?
fillpatternTableconstantTable with standard fill patterns.
G1024x768x16constantMode: Resolution 1024x768, 16 colors.
G1024x768x16MconstantMode: Resolution 1024x768, 16M colors.
G1024x768x16M32constantMode: Resolution 1024x758, 16M 32-bit colors.
G1024x768x256constantMode: Resolution 1024x768, 256 colors.
G1024x768x32KconstantMode: Resolution 1024x768, 32K colors.
G1024x768x64KconstantMode: Resolution 1024x768, 64K colors.
G1152x864x16constantMode: Resolution 1152x864, 16 colors.
G1152x864x16MconstantMode: Resolution 1152x864, 16M colors.
G1152x864x16M32constantMode: Resolution 1152x864, 16M 32-bitcolors.
G1152x864x256constantMode: Resolution 1152x864, 256 colors.
G1152x864x32KconstantMode: Resolution 1152x864, 32K colors.
G1152x864x64KconstantMode: Resolution 1152x864, 64K colors.
G1280x1024x16constantMode: Resolution 1280x1024, 16 colors.
G1280x1024x16MconstantMode: Resolution 1280x1024, 16M colors.
G1280x1024x16M32constantMode: Resolution 1280x1024, 16M 32-bit colors.
G1280x1024x256constantMode: Resolution 1280x1024, 256 colors.
G1280x1024x32KconstantMode: Resolution 1280x1024, 32K colors.
G1280x1024x64KconstantMode: Resolution 1280x1024, 64K colors.
G1600x1200x16constantMode: Resolution 1600x1200, 16 colors.
G1600x1200x16MconstantMode: Resolution 1600x1200, 16M colors.
G1600x1200x16M32constantMode: Resolution 1600x1200, 16M 32-bit colors.
G1600x1200x256constantMode: Resolution 1600x1200, 256 colors.
G1600x1200x32KconstantMode: Resolution 1600x1200, 32K colors.
G1600x1200x64KconstantMode: Resolution 1600x1200, 64K colors.
G320x200x16constantMode: Resulution 320x200, 16 colors.
G320x200x16MconstantMode: Resolution 320x200, 16M colors.
G320x200x16M32constantMode: Resolution 320x200, 16M 32-bit colors.
G320x200x256constantMode: Resolution 320x200, 256 colors.
G320x200x32KconstantMode: Resolution 320x200, 32K colors.
G320x200x64KconstantMode: Resolution 320x200, 64K colors.
G320x240x256constantMode: Resolution 320x240, 256 colors.
G320x400x256constantMode: Resolution 320x400, 256 colors.
G360x480x256constantMode: Resolution 360x480, 256 colors.
G640x200x16constantMode: Resolution x, colors.
G640x350x16constantMode: Resolution x, colors.
G640x480x16constantMode: Resolution x, colors.
G640x480x16MconstantMode: Resolution 640x480, 16M colors.
G640x480x16M32constantMode: Resolution 640x480, 16M 32-bit colors.
G640x480x2constantMode: Resolution 640x480, 2 colors.
G640x480x256constantMode: Resolution 640x480, 256 colors.
G640x480x32KconstantMode: Resolution 640x480, 32K colors.
G640x480x64KconstantMode: Resolution 640x480, 64K colors.
G720x348x2constantMode: Resolution 720x348, 2 colors.
G800x600x16constantMode: Resolution 800x600, 16 colors.
G800x600x16MconstantMode: Resolution 800x600, 16M colors.
G800x600x16M32constantMode: Resolution 800x600, 16M 32-bit colors.
G800x600x256constantMode: Resolution 800x600, 256 colors.
G800x600x32KconstantMode: Resolution 800x600, 32K colors.
G800x600x64KconstantMode: Resolution 800x600, 64K colors.
GothicFontconstantFont number: Gothic font.
GraphStringTransTableconstantTable used when transliterating strings.
greenconstantColor code: green.
grErrorconstantError: Unknown error.
grFileNotFoundconstantError: File for driver not found.
grFontNotFoundconstantError: font description file not found.
grInvalidDriverconstantError: Invalid driver specified.
grInvalidFontconstantError: Invalid font description.
grInvalidFontNumconstantError: Invalid font number.
grInvalidModeconstantError: Invalid mode specified.
grInvalidVersionconstantError: Invalid version.
grIOerrorconstantError: Unspecified Input/Output error.
grNoFloodMemconstantError: Could not allocate memory for flood operation.
grNoFontMemconstantError: Not enough memory to load font.
grNoInitGraphconstantError: Graphical system not initialized.
grNoLoadMemconstantError: Memory error.
grNoScanMemconstantError: Could not allocate memory for scan.
grNotDetectedconstantError: Graphics device not detected.
grOkconstantGraphical operation went OK.
HatchFillconstantFill style: Hatch lines.
HercMonoconstantMode: Hercules, mono color.
HercMonoHiconstantMode: Hercules card, monochrome, high resolution.
highNewDriverconstantMode: highest number for new driver.
highNewModeconstantMode: Highest possible value of the new modes.
HorizDirconstantText write direction: Horizontal.
InterleaveFillconstantFill style: Interleaving lines.
LCOMFontconstantFont number: ?
LeftTextconstantHorizontal text alignment: Align text left.
lightblueconstantColor code: Light blue.
lightcyanconstantColor code: Light cyan.
lightgrayconstantColor code: Light gray.
lightgreenconstantColor code: Light green.
lightmagentaconstantColor code: Light magenta.
lightredconstantColor code: Light red.
LineFillconstantFill style: Fill using horizontal lines.
lowNewDriverconstantMode: lowest number for new driver.
lowNewModeconstantMode: Lowest possible value of the new modes.
LowResconstantMode: Low resolution.
LtBkSlashFillconstantFill style: Light diagonal (backslash) lines.
LtSlashFillconstantFill style: Light diagonal (slash) lines.
m1024x768constantMode: Resolution 1024x768.
m1280x1024constantMode: Resolution 1280x1024.
m1600x1200constantMode: Resolution 1600x1200.
m2048x1536constantMode: Resolution 2048x1536.
m320x200constantMode: Resolution 320x200.
m320x256constantMode: Resolution 320x256.
m320x400constantMode: Resolution 320x400.
m512x384constantMode: Resolution 512x384.
m640x200constantMode: Resolution 640x200.
m640x256constantMode: Resolution 640x256.
m640x350constantMode: Resolution 640x350.
m640x400constantMode: Resolution 640x400.
m640x480constantMode: Resolution 640x480.
m800x600constantMode: Resolution 800x600.
m832x624constantMode: Resolution 832x624.
magentaconstantColor code: Magenta.
MaxColorsconstantMax amount of colors in a palette.
maxsmallintconstantMaximum value for smallint type.
MCGAconstantGraphic driver for MCGA cards.
MCGAC0constantMCGA Graphic driver mode C0.
MCGAC1constantMCGA Graphic driver mode C1.
MCGAC2constantMCGA Graphic driver mode C2.
MCGAC3constantMCGA Graphic driver mode C3.
MCGAHiconstantMCGA Graphic driver high resolution mode.
MCGAMedconstantMCGA Graphic driver medium resolution mode.
NormalPutconstantDraw operation: Use Normal (copy) operation.
NormWidthconstantLine width: Normal width.
NotPutconstantDraw operation: use NOT.
OrPutconstantDraw operation: use OR.
redconstantColor code: Red.
resolutionsconstantArray with actual resolutions of the new modes.
RightTextconstantHorizontal text alignment: Align text right.
SansSerifFontconstantFont number: Sans Serif font.
ScriptFontconstantFont number: Script font.
SimpleFontconstantFont number: Simple font.
SlashFillconstantFill style: Diagonal (slash) lines.
SmallFontconstantFont number: Small font.
SolidFillconstantFill style: Solid fill.
SolidLnconstantLine style: Solid line.
ThickWidthconstantLine width: double width.
TopOffconstantTop off.
TopOnconstantTop on.
TopTextconstantVertical text alignment: Align text to top.
TriplexFontconstantFont number: Triplex font.
TSCRFontconstantFont number: Terminal font.
UserBitLnconstantLine style: User defined.
UserCharSizeconstantUser character size.
UserFillconstantFill style: User-defined fill.
VertDirconstantText write direction: Vertical.
VESAconstantMode: VESA graphics adaptor.
VGAconstantMode: VGA graphics adaptor.
VGAHiconstantMode: VGA high resolution (640x480).
VGALoconstantMode: VGA low resolution (640x200).
VGAMedconstantMode: VGA medium resolution (640x350).
whiteconstantColor code: White.
WideDotFillconstantFill style: Widely spaced dotted lines.
XHatchFillconstantFill style: Heavy hatch lines.
XORPutconstantDraw operation: use XOR.
yellowconstantColor code: Yellow.

Variables

CirclevariableDraw a complete circle.
ClearViewPortvariableClear the current viewport.
DirectPutPixelvariableHook to directly draw a pixel on the screen.
GetBkColorvariableReturn current background color.
GetImagevariableReturn a copy of a screen area.
GetPixelvariableReturn color of pixel.
GetRGBPalettevariableHook to set a RGB palette entries.
GetScanLinevariableHook to get a scan line from the screen.
GraphFreeMemPtrvariableHook to free heap memory.
GraphGetMemPtrvariableHook to get heap memory.
HLinevariableHook to draw a solid horizontal line.
ImageSizevariableReturn size to store image.
InternalEllipsevariableHook to draw an ellipse.
LinevariableDraw a line between 2 points.
OutTextXYvariableWrite text on the screen on given position.
PatternLinevariableHook to draw a patterned line.
PutImagevariableDraw an in-memory image to the screen.
PutPixelvariableDraw a pixel on the screen.
RestoreVideoStatevariableHook to restore a saved video mode.
SaveVideoStatevariableHook to save the current video state.
SetActivePagevariableSet active graphical page.
SetAllPalettevariableSpecify a complete new palette.
SetBkColorvariableSet background drawing color.
SetRGBPalettevariableSet palette entry using RGB value.
SetVisualPagevariableSet video page which is displayed.
VLinevariableHook to draw a solid vertical line.

Topics

FuncColorManagementtopicCategorized functions: Color management.
FuncDrawingtopicCategorized functions: Drawing primitives.
FuncFilledDrawingtopicCategorized functions: Filled drawings.
FuncInitializiontopicCategorized functions: Initialization.
FuncScreentopicCategorized functions: Screen management.
FuncTextHandlingtopicCategorized functions: Text and font handling.
ModestopicA word about mode selection.
RequirementstopicRequirements.
TargetIssuesDostopicTarget specific issues: DOS.
TargetIssuesWindowstopicTarget specific issues: Linux.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.