Subsections
graphex
This document describes the GRAPH unit for Free Pascal, for all
platforms. The unit was first written for DOS by Florian klämpfl, but was
later completely rewritten by Carl-Eric Codere to be completely portable.
This chapter is divided in 4 sections.
- The first section gives an introduction to the graph unit.
- The second section lists the pre-defined constants, types and variables.
- The second section describes the functions which appear in the
interface part of the GRAPH unit.
- The last part describes some system-specific issues.
8.1 Introduction
The unit Graph exports functions and procedures for graphical output.
It requires at least a VGA-compatible Card or a VGA-Card with software-driver
(min. 512Kb video memory).
The graph unit was implemented for compatibility with the old graph
unit. For this reason, the mode constants as they were defined in the
graph unit are retained.
However, since
- Video cards have evolved very much
- Free Pascal runs on multiple platforms
it was decided to implement new mode and graphic driver constants,
which are more independent of the specific platform the program runs on.
In this section we give a short explanation of the new mode system. the
following drivers were defined:
D1bit = 11;
D2bit = 12;
D4bit = 13;
D6bit = 14; { 64 colors Half-brite mode - Amiga }
D8bit = 15;
D12bit = 16; { 4096 color modes HAM mode - Amiga }
D15bit = 17;
D16bit = 18;
D24bit = 19; { not yet supported }
D32bit = 20; { not yet supported }
D64bit = 21; { not yet supported }
lowNewDriver = 11;
highNewDriver = 21;
Each of these drivers specifies a desired color-depth.
The following modes have been defined:
detectMode = 30000;
m320x200 = 30001;
m320x256 = 30002; { amiga resolution (PAL) }
m320x400 = 30003; { amiga/atari resolution }
m512x384 = 30004; { mac resolution }
m640x200 = 30005; { vga resolution }
m640x256 = 30006; { amiga resolution (PAL) }
m640x350 = 30007; { vga resolution }
m640x400 = 30008;
m640x480 = 30009;
m800x600 = 30010;
m832x624 = 30011; { mac resolution }
m1024x768 = 30012;
m1280x1024 = 30013;
m1600x1200 = 30014;
m2048x1536 = 30015;
lowNewMode = 30001;
highNewMode = 30015;
These modes start at 30000 because Borland specified that the mode number
should be ascending with increasing X resolution, and the new constants
shouldn't interfere with the old ones.
The above constants can be used to set a certain color depth and resultion,
as demonstrated in the following example:
-
Example
Program inigraph1;
{ Program to demonstrate static graphics mode selection }
uses graph;
const
TheLine = 'We are now in 640 x 480 x 256 colors!'+
' (press <Return> to continue)';
var
gd, gm, lo, hi, error,tw,th: integer;
found: boolean;
begin
{ We want an 8 bit mode }
gd := D8bit;
gm := m640x480;
initgraph(gd,gm,'');
{ Make sure you always check graphresult! }
error := graphResult;
if (error <> grOk) Then
begin
writeln('640x480x256 is not supported!');
halt(1)
end;
{ We are now in 640x480x256 }
setColor(cyan);
rectangle(0,0,getmaxx,getmaxy);
{ Write a nice message in the center of the screen }
setTextStyle(defaultFont,horizDir,1);
tw:=TextWidth(TheLine);
th:=TextHeight(TheLine);
outTextXY((getMaxX - TW) div 2,
(getMaxY - TH) div 2,TheLine);
{ Wait for return }
readln;
{ Back to text mode }
closegraph;
end.
If other modes than the ones above are supported by the graphics card,
you will not be able to select them with this mechanism.
For this reason, there is also a 'dynamic' mode number, which is assigned at
run-time. This number increases with increasing X resolution. It can be
queried with the getmoderange call. This call will return the range
of modes which are valid for a certain graphics driver. The numbers are
guaranteed to be consecutive, and can be used to search for a certain
resolution, as in the following example:
-
Example
Program inigraph2;
{ Program to demonstrate dynamic graphics mode selection }
uses graph;
const
TheLine = 'We are now in 640 x 480 x 256 colors!'+
' (press <Return> to continue)';
var
th,tw,gd, gm, lo, hi, error: integer;
found: boolean;
begin
{ We want an 8 bit mode }
gd := D8bit;
{ Get all available resolutions for this bitdepth }
getmoderange(gd,lo,hi);
{ If the highest available mode number is -1,
no resolutions are supported for this bitdepth }
if hi = -1 then
begin
writeln('no 8 bit modes supported!');
halt
end;
found := false;
{ Search all resolutions for 640x480 }
for gm := lo to hi do
begin
initgraph(gd,gm,'');
{ Make sure you always check graphresult! }
error := graphResult;
if (error = grOk) and
(getmaxx = 639) and (getmaxy = 479) then
begin
found := true;
break;
end;
end;
if not found then
begin
writeln('640x480x256 is not supported!');
halt(1)
end;
{ We are now in 640x480x256 }
setColor(cyan);
rectangle(0,0,getmaxx,getmaxy);
{ Write a nice message in the center of the screen }
setTextStyle(defaultFont,horizDir,1);
TW:=TextWidth(TheLine);
TH:=TextHeight(TheLine);
outTextXY((getMaxX - TW) div 2,
(getMaxY - TH) div 2,TheLine);
{ Wait for return }
readln;
{ Back to text mode }
closegraph;
end.
Thus, the getmoderange function can be used to detect all available
modes and drivers, as in the following example:
-
Example
Program GetModeRange_Example;
{ This program demonstrates how to find all available graph modes }
uses graph;
const
{ Currently, only 4, 8, 15 and 16 bit modes are supported
but this may change in the future }
gdnames: array[D4bit..D16bit] of string[6] =
('4 bit','6 bit','8 bit','12 bit','15 bit','16 bit');
var
t: text;
gd, c, low, high, res: integer;
begin
assign(t,'modes.txt');
rewrite(t);
close(t);
for gd := D4bit to D16bit do
begin
{ Get the available mode numbers for this driver }
getModeRange(gd,low,high);
append(t);
write(t,gdnames[gd]);
Writeln(t,': low modenr = ',low,', high modenr = ',high);
close(t);
{ If high is -1,
no resolutions are supported for this bitdepth }
if high = -1 then
begin
append(t);
writeln(t,' No modes supported!');
writeln(t);
close(t);
end
else
{ Enter all supported resolutions for this bitdepth
and write their characteristics to the file }
for c := low to high do
begin
append(t);
writeln(t,' testing mode nr ',c);
close(t);
initgraph(gd,c,'');
res := graphresult;
append(t);
{ An error occurred when entering the mode? }
if res <> grok then
writeln(t,grapherrormsg(res))
else
begin
write(t,'maxx: ',getmaxx,', maxy: ',getmaxy);
Writeln(t,', maxcolor: ',getmaxcolor);
closegraph;
end;
writeln(t);
close(t);
end;
append(t);
writeln(t);
close(t);
end;
end.
ArcCoordsType = record
X,Y,Xstart,Ystart,Xend,Yend : Integer;
end;
FillPatternType = Array [1..8] of Byte;
FillSettingsType = Record
Pattern,Color : Word
end;
LineSettingsType = Record
LineStyle,Pattern, Width : Word;
end;
PaletteType = Record
Size : Byte;
Colors : array[0..MAxColor] of shortint;
end;
PointType = Record
X,Y : Integer;
end;
TextSettingsType = Record
Font,Direction, CharSize, Horiz, Vert : Word
end;
ViewPortType = Record
X1,Y1,X2,Y2 : Integer;
Clip : Boolean
end;
What follows is a listing of the available functions, grouped by category.
For each function there is a reference to the page where you can find the
function.
Initialization of the graphics screen.
ClearDevice Empty the graphics screen]
- CloseGraph Finish drawing session, return to text mode
- DetectGraph Detect graphical modes
- GetAspectRatio Get aspect ratio of screen
- GetModeRange Get range of valid modes for current driver
- GraphDefaults Set defaults
- GetDriverName Return name of graphical driver
- GetGraphMode Return current or last used graphics mode
- GetMaxMode Get maximum mode for current driver
- GetModeName Get name of current mode
- GraphErrorMsg String representation of graphical error
- GraphResult Result of last drawing operation
- InitGraph Initialize graphics drivers
- InstallUserDriver Install a new driver
- RegisterBGIDriver Register a new driver
- RestoreCRTMode Go back to text mode
- SetGraphBufSize Set buffer size for graphical operations
- SetGraphMode Set graphical mode
-
General drawing screen management functions.
ClearViewPort Clear the current viewport]
- GetImage Copy image from screen to memory
- GetMaxX Get maximum X coordinate
- GetMaxY Get maximum Y coordinate
- GetX Get current X position
- GetY Get current Y position
- ImageSize Get size of selected image
- GetViewSettings Get current viewport settings
- PutImage Copy image from memory to screen
- SetActivePage Set active video page
- SetAspectRatio Set aspect ratio for drawing routines
- SetViewPort Set current viewport
- SetVisualPage Set visual page
- SetWriteMode Set write mode for screen operations
-
All functions related to color management.
GetBkColor Get current background color]
- GetColor Get current foreground color
- GetDefaultPalette Get default palette entries
- GetMaxColor Get maximum valid color
- GetPaletteSize Get size of palette for current mode
- GetPixel Get color of selected pixel
- GetPalette Get palette entry
- SetAllPallette Set all colors in palette
- SetBkColor Set background color
- SetColor Set foreground color
- SetPalette Set palette entry
- SetRGBPalette Set palette entry with RGB values
-
Functions for simple drawing.
Arc Draw an arc]
- Circle Draw a complete circle
- DrawPoly Draw a polygone with N points
- Ellipse Draw an ellipse
- GetArcCoords Get arc coordinates
- GetLineSettings Get current line drawing settings
- Line Draw line between 2 points
- LineRel Draw line relative to current position
- LineTo Draw line from current position to absolute position
- MoveRel Move cursor relative to current position
- MoveTo Move cursor to absolute position
- PieSlice Draw a pie slice
- PutPixel Draw 1 pixel
- Rectangle Draw a non-filled rectangle
- Sector Draw a sector
- SetLineStyle Set current line drawing style
-
Functions for drawing filled regions.
Bar3D Draw a filled 3D-style bar]
- Bar Draw a filled rectangle
- FloodFill Fill starting from coordinate
- FillEllipse Draw a filled ellipse
- FillPoly Draw a filled polygone
- GetFillPattern Get current fill pattern
- GetFillSettings Get current fill settings
- SetFillPattern Set current fill pattern
- SetFillStyle Set current fill settings
-
Functions to set texts on the screen.
GetTextSettings Get current text settings]
- InstallUserFont Install a new font
- OutText Write text at current cursor position
- OutTextXY Write text at coordinates X,Y
- RegisterBGIFont Register a new font
- SetTextJustify Set text justification
- SetTextStyle Set text style
- SetUserCharSize Set text size
- TextHeight Calculate height of text
- TextWidth Calculate width of text
-
8.4.1 Arc
-
Declaration
- Procedure Arc (X,Y : Integer; start,stop, radius : Word);
-
Description
Arc draws part of a circle with center at (X,Y), radius
radius, starting from angle start, stopping at angle stop.
These angles are measured
counterclockwise.
-
Errors
- None.
-
See also
- Circle,Ellipse
GetArcCoords,PieSlice, Sector
8.4.2 Bar
-
Declaration
- Procedure Bar (X1,Y1,X2,Y2 : Integer);
-
Description
Draws a rectangle with corners at (X1,Y1) and (X2,Y2)
and fills it with the current color and fill-style.
-
Errors
- None.
-
See also
- Bar3D,
Rectangle
8.4.3 Bar3D
-
Declaration
- Procedure Bar3D (X1,Y1,X2,Y2 : Integer; depth : Word; Top : Boolean);
-
Description
Draws a 3-dimensional Bar with corners at (X1,Y1) and (X2,Y2)
and fills it with the current color and fill-style.
Depth specifies the number of pixels used to show the depth of the
bar.
If Top is true; then a 3-dimensional top is drawn.
-
Errors
- None.
-
See also
- Bar, Rectangle
8.4.4 Circle
-
Declaration
- Procedure Circle (X,Y : Integer; Radius : Word);
-
Description
Circle draws part of a circle with center at (X,Y), radius
radius.
-
Errors
- None.
-
See also
- Ellipse,Arc
GetArcCoords,PieSlice, Sector
8.4.5 ClearDevice
-
Declaration
- Procedure ClearDevice ;
-
Description
Clears the graphical screen (with the current
background color), and sets the pointer at (0,0)
-
Errors
- None.
-
See also
- ClearViewPort, SetBkColor
8.4.6 ClearViewPort
-
Declaration
- Procedure ClearViewPort ;
-
Description
Clears the current viewport. The current background color is used as filling
color. The pointer is set at
(0,0)
-
Errors
- None.
-
See also
- ClearDevice,SetViewPort, SetBkColor
8.4.7 CloseGraph
-
Declaration
- Procedure CloseGraph ;
-
Description
Closes the graphical system, and restores the
screen modus which was active before the graphical modus was
activated.
-
Errors
- None.
-
See also
- InitGraph
8.4.8 DetectGraph
-
Declaration
- Procedure DetectGraph (Var Driver, Modus : Integer);
-
Description
Checks the hardware in the PC and determines the driver and screen-modus to
be used. These are returned in Driver and Modus, and can be fed
to InitGraph.
See the InitGraph for a list of drivers and modi.
-
Errors
- None.
-
See also
- InitGraph
8.4.9 DrawPoly
-
Declaration
- Procedure DrawPoly (NumberOfPoints : Word; Var PolyPoints;
-
Description
Draws a polygone with NumberOfPoints corner points, using the
current color and line-style. PolyPoints is an array of type PointType.
-
Errors
- None.
-
See also
- Bar, seepBar3D, Rectangle
8.4.10 Ellipse
-
Declaration
- Procedure Ellipse (X,Y : Integer; Start,Stop,XRadius,YRadius : Word);
-
Description
Ellipse draws part of an ellipse with center at (X,Y).
XRadius and Yradius are the horizontal and vertical radii of the
ellipse. Start and Stop are the starting and stopping angles of
the part of the ellipse.
They are measured counterclockwise from the X-axis.
-
Errors
- None.
-
See also
- Arc Circle, FillEllipse
8.4.11 FillEllipse
-
Declaration
- Procedure FillEllipse (X,Y : Integer; Xradius,YRadius: Word);
-
Description
Ellipse draws an ellipse with center at (X,Y).
XRadius and Yradius are the horizontal and vertical radii of the
ellipse. The ellipse is filled with the current color and fill-style.
-
Errors
- None.
-
See also
- Arc Circle,
GetArcCoords,PieSlice, Sector
8.4.12 FillPoly
-
Declaration
- Procedure FillPoly (NumberOfPoints : Word; Var PolyPoints);
-
Description
Draws a polygone with NumberOfPoints corner points and fills it
using the current color and line-style.
PolyPoints is an array of type PointType.
-
Errors
- None.
-
See also
- Bar, seepBar3D, Rectangle
8.4.13 FloodFill
-
Declaration
- Procedure FloodFill (X,Y : Integer; BorderColor : Word);
-
Description
Fills the area containing the point (X,Y), bounded by the color
BorderColor.
-
Errors
- None
-
See also
- SetColor, SetBkColor
8.4.14 GetArcCoords
-
Declaration
- Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
-
Description
- GetArcCoords
returns the coordinates of the latest Arc or
Ellipse call.
-
Errors
- None.
-
See also
- Arc, Ellipse
8.4.15 GetAspectRatio
-
Declaration
- Procedure GetAspectRatio (Var Xasp,Yasp : Word);
-
Description
- GetAspectRatio
determines the effective resolution of the screen. The aspect ration can
the be calculated as Xasp/Yasp.
-
Errors
- None.
-
See also
- InitGraph,SetAspectRatio
8.4.16 GetBkColor
-
Declaration
- Function GetBkColor : Word;
-
Description
- GetBkColor
returns the current background color (the palette
entry).
-
Errors
- None.
-
See also
- GetColor,SetBkColor
8.4.17 GetColor
-
Declaration
- Function GetColor : Word;
-
Description
- GetColor
returns the current drawing color (the palette
entry).
-
Errors
- None.
-
See also
- GetColor,SetBkColor
8.4.18 GetDefaultPalette
-
Declaration
- Procedure GetDefaultPalette (Var Palette : PaletteType);
-
Description
Returns the
current palette in Palette.
-
Errors
- None.
-
See also
- GetColor, GetBkColor
8.4.19 GetDriverName
-
Declaration
- Function GetDriverName : String;
-
Description
- GetDriverName
returns a string containing the name of the
current driver.
-
Errors
- None.
-
See also
- GetModeName, InitGraph
8.4.20 GetFillPattern
-
Declaration
- Procedure GetFillPattern (Var FillPattern : FillPatternType);
-
Description
- GetFillPattern
returns an array with the current fill-pattern in FillPattern
-
Errors
- None
-
See also
- SetFillPattern
8.4.21 GetFillSettings
-
Declaration
- Procedure GetFillSettings (Var FillInfo : FillSettingsType);
-
Description
- GetFillSettings
returns the current fill-settings in
FillInfo
-
Errors
- None.
-
See also
- SetFillPattern
8.4.22 GetGraphMode
-
Declaration
- Function GetGraphMode : Integer;
-
Description
- GetGraphMode
returns the current graphical modus
-
Errors
- None.
-
See also
- InitGraph
8.4.23 GetImage
-
Declaration
- Procedure GetImage (X1,Y1,X2,Y2 : Integer, Var Bitmap;
-
Description
- GetImage
Places a copy of the screen area (X1,Y1) to X2,Y2 in BitMap
-
Errors
- Bitmap must have enough room to contain the image.
-
See also
- ImageSize,
PutImage
8.4.24 GetLineSettings
-
Declaration
- Procedure GetLineSettings (Var LineInfo : LineSettingsType);
-
Description
- GetLineSettings
returns the current Line settings in
LineInfo
-
Errors
- None.
-
See also
- SetLineStyle
8.4.25 GetMaxColor
-
Declaration
- Function GetMaxColor : Word;
-
Description
- GetMaxColor
returns the maximum color-number which can be
set with SetColor. Contrary to , this color isn't always
guaranteed to be white (for instance in 256+ color modes).
-
Errors
- None.
-
See also
- SetColor,
GetPaletteSize
8.4.26 GetMaxMode
-
Declaration
- Function GetMaxMode : Word;
-
Description
- GetMaxMode
returns the highest modus for
the current driver.
-
Errors
- None.
-
See also
- InitGraph
8.4.27 GetMaxX
-
Declaration
- Function GetMaxX : Word;
-
Description
- GetMaxX
returns the maximum horizontal screen
length
-
Errors
- None.
-
See also
- GetMaxY
8.4.28 GetMaxY
-
Declaration
- Function GetMaxY : Word;
-
Description
- GetMaxY
returns the maximum number of screen
lines
-
Errors
- None.
-
See also
- GetMaxY
8.4.29 GetModeName
-
Declaration
- Function GetModeName (Var modus : Integer) : String;
-
Description
Returns a string with the name of modus
Modus
-
Errors
- None.
-
See also
- GetDriverName, InitGraph
8.4.30 GetModeRange
-
Declaration
- Procedure GetModeRange (Driver : Integer;
LoModus, HiModus: Integer);
-
Description
- GetModeRange
returns the Lowest and Highest modus of the currently
installed driver. If no modes are supported for this driver, HiModus
will be -1.
-
Errors
- None.
-
See also
- InitGraph
8.4.31 GetPalette
-
Declaration
- Procedure GetPalette (Var Palette : PaletteType);
-
Description
- GetPalette
returns in Palette the current palette.
-
Errors
- None.
-
See also
- GetPaletteSize, SetPalette
8.4.32 GetPaletteSize
-
Declaration
- Function GetPaletteSize : Word;
-
Description
- GetPaletteSize
returns the maximum
number of entries in the current palette.
-
Errors
- None.
-
See also
- GetPalette,
SetPalette
8.4.33 GetPixel
-
Declaration
- Function GetPixel (X,Y : Integer) : Word;
-
Description
- GetPixel
returns the color
of the point at (X,Y)
-
Errors
- None.
-
See also
8.4.34 GetTextSettings
-
Declaration
- Procedure GetTextSettings (Var TextInfo : TextSettingsType);
-
Description
- GetTextSettings
returns the current text style settings : The font,
direction, size and placement as set with SetTextStyle and
SetTextJustify
-
Errors
- None.
-
See also
- SetTextStyle, SetTextJustify
8.4.35 GetViewSettings
-
Declaration
- Procedure GetViewSettings (Var ViewPort : ViewPortType);
-
Description
- GetViewSettings
returns the current viewport and clipping settings in
ViewPort.
-
Errors
- None.
-
See also
- SetViewPort
8.4.36 GetX
-
Declaration
- Function GetX : Integer;
-
Description
- GetX
returns the X-coordinate of the current position of
the graphical pointer
-
Errors
- None.
-
See also
- GetY
8.4.37 GetY
-
Declaration
- Function GetY : Integer;
-
Description
- GetY
returns the Y-coordinate of the current position of
the graphical pointer
-
Errors
- None.
-
See also
- GetX
8.4.38 GraphDefaults
-
Declaration
- Procedure GraphDefaults ;
-
Description
- GraphDefaults
resets all settings for viewport, palette,
foreground and background pattern, line-style and pattern, filling style,
filling color and pattern, font, text-placement and
text size.
-
Errors
- None.
-
See also
- SetViewPort, SetFillStyle, SetColor,
SetBkColor, SetLineStyle
8.4.39 GraphErrorMsg
-
Declaration
- Function GraphErrorMsg (ErrorCode : Integer) : String;
-
Description
- GraphErrorMsg
returns a string describing the error Errorcode. This string can be
used to let the user know what went wrong.
-
Errors
- None.
-
See also
- GraphResult
8.4.40 GraphResult
-
Declaration
- Function GraphResult : Integer;
-
Description
- GraphResult
returns an error-code for
the last graphical operation. If the returned value is zero, all went well.
A value different from zero means an error has occurred.
besides all operations which draw something on the screen,
the following procedures also can produce a GraphResult different from
zero:
-
Errors
- None.
-
See also
- GraphErrorMsg
8.4.41 ImageSize
-
Declaration
- Function ImageSize (X1,Y1,X2,Y2 : Integer) : Word;
-
Description
- ImageSize
returns
the number of bytes needed to store the image in the rectangle defined by
(X1,Y1) and (X2,Y2).
-
Errors
- None.
-
See also
- GetImage
8.4.42 InitGraph
-
Declaration
- Procedure InitGraph (var GraphDriver,GraphModus : integer;
const PathToDriver : string);
-
Description
InitGraph initializes the graph package.
GraphDriver has two valid values: GraphDriver=0 which
performs an auto detect and initializes the highest possible mode with the most
colors. 1024x768x64K is the highest possible resolution supported by the
driver, if you need a higher resolution, you must edit MODES.PPI.
If you need another mode, then set GraphDriver to a value different
from zero
and graphmode to the mode you wish (VESA modes where 640x480x256
is 101h etc.).
PathToDriver is only needed, if you use the BGI fonts from
Borland.
-
Errors
- None.
-
See also
- Introduction, (page ),
DetectGraph, CloseGraph, GraphResult
Example:
var
gd,gm : integer;
PathToDriver : string;
begin
gd:=detect; { highest possible resolution }
gm:=0; { not needed, auto detection }
PathToDriver:='C:\PP\BGI'; { path to BGI fonts,
drivers aren't needed }
InitGraph(gd,gm,PathToDriver);
if GraphResult<>grok then
halt; ..... { whatever you need }
CloseGraph; { restores the old graphics mode }
end.
8.4.43 InstallUserDriver
-
Declaration
- Function InstallUserDriver (DriverPath : String;
AutoDetectPtr: Pointer) : Integer;
-
Description
- InstallUserDriver
adds the device-driver DriverPath to the list of .BGI
drivers. AutoDetectPtr is a pointer to a possible auto-detect function.
-
Errors
- None.
-
See also
- InitGraph, InstallUserFont
8.4.44 InstallUserFont
-
Declaration
- Function InstallUserFont (FontPath : String) : Integer;
-
Description
- InstallUserFont
adds the font in FontPath to the list of fonts
of the .BGI system.
-
Errors
- None.
-
See also
- InitGraph, InstallUserDriver
8.4.45 Line
-
Declaration
- Procedure Line (X1,Y1,X2,Y2 : Integer);
-
Description
- Line
draws a line starting from
(X1,Y1 to (X2,Y2), in the current line style and color. The
current position is put to (X2,Y2)
-
Errors
- None.
-
See also
- LineRel,LineTo
8.4.46 LineRel
-
Declaration
- Procedure LineRel (DX,DY : Integer);
-
Description
- LineRel
draws a line starting from
the current pointer position to the point(DX,DY, relative to the
current position, in the current line style and color. The Current Position
is set to the endpoint of the line.
-
Errors
- None.
-
See also
- Line, LineTo
8.4.47 LineTo
-
Declaration
- Procedure LineTo (DX,DY : Integer);
-
Description
- LineTo
draws a line starting from
the current pointer position to the point(DX,DY, relative to the
current position, in the current line style and color. The Current position
is set to the end of the line.
-
Errors
- None.
-
See also
- LineRel,Line
8.4.48 MoveRel
-
Declaration
- Procedure MoveRel (DX,DY : Integer;
-
Description
- MoveRel
moves the pointer to the
point (DX,DY), relative to the current pointer
position
-
Errors
- None.
-
See also
- MoveTo
8.4.49 MoveTo
-
Declaration
- Procedure MoveTo (X,Y : Integer;
-
Description
- MoveTo
moves the pointer to the
point (X,Y).
-
Errors
- None.
-
See also
- MoveRel
8.4.50 OutText
-
Declaration
- Procedure OutText (Const TextString : String);
-
Description
- OutText
puts TextString on the screen, at the current pointer
position, using the current font and text settings. The current position is
moved to the end of the text.
-
Errors
- None.
-
See also
- OutTextXY
8.4.51 OutTextXY
-
Declaration
- Procedure OutTextXY (X,Y : Integer; Const TextString : String);
-
Description
- OutText
puts TextString on the screen, at position (X,Y),
using the current font and text settings. The current position is
moved to the end of the text.
-
Errors
- None.
-
See also
- OutText
8.4.52 PieSlice
-
Declaration
- Procedure PieSlice (X,Y : Integer;
Start,Stop,Radius : Word);
-
Description
- PieSlice
draws and fills a sector of a circle with center (X,Y) and radius
Radius, starting at angle Start and ending at angle Stop.
-
Errors
- None.
-
See also
- Arc, Circle, Sector
8.4.53 PutImage
-
Declaration
- Procedure PutImage (X1,Y1 : Integer; Var Bitmap; How : word) ;
-
Description
- PutImage
Places the bitmap in Bitmap on the screen at (X1,Y1). How
determines how the bitmap will be placed on the screen. Possible values are :
- CopyPut
- XORPut
- ORPut
- AndPut
- NotPut
-
Errors
- None
-
See also
- ImageSize,GetImage
8.4.54 PutPixel
-
Declaration
- Procedure PutPixel (X,Y : Integer; Color : Word);
-
Description
Puts a point at
(X,Y) using color Color
-
Errors
- None.
-
See also
- GetPixel
8.4.55 Rectangle
-
Declaration
- Procedure Rectangle (X1,Y1,X2,Y2 : Integer);
-
Description
Draws a rectangle with
corners at (X1,Y1) and (X2,Y2), using the current color and
style.
-
Errors
- None.
-
See also
- Bar, Bar3D
8.4.56 RegisterBGIDriver
-
Declaration
- Function RegisterBGIDriver (Driver : Pointer) : Integer;
-
Description
Registers a user-defined BGI driver
-
Errors
- None.
-
See also
- InstallUserDriver,
RegisterBGIFont
8.4.57 RegisterBGIFont
-
Declaration
- Function RegisterBGIFont (Font : Pointer) : Integer;
-
Description
Registers a user-defined BGI driver
-
Errors
- None.
-
See also
- InstallUserFont,
RegisterBGIDriver
8.4.58 RestoreCRTMode
-
Declaration
- Procedure RestoreCRTMode ;
-
Description
Restores the screen modus which was active before
the graphical modus was started.
To get back to the graph mode you were last in, you can use
SetGraphMode(GetGraphMode)
-
Errors
- None.
-
See also
- InitGraph
8.4.59 Sector
-
Declaration
- Procedure Sector (X,Y : Integer;
Start,Stop,XRadius,YRadius : Word);
-
Description
- Sector
draws and fills a sector of an ellipse with center (X,Y) and radii
XRadius and YRadius, starting at angle Start and ending at angle Stop.
-
Errors
- None.
-
See also
- Arc, Circle, PieSlice
8.4.60 SetActivePage
-
Declaration
- Procedure SetActivePage (Page : Word);
-
Description
Sets Page as the active page
for all graphical output.
-
Errors
- None.
-
See also
8.4.61 SetAllPallette
-
Declaration
- Procedure SetAllPallette (Var Palette);
-
Description
Sets the current palette to
Palette. Palette is an untyped variable, usually pointing to a
record of type PaletteType
-
Errors
- None.
-
See also
- GetPalette
8.4.62 SetAspectRatio
-
Declaration
- Procedure SetAspectRatio (Xasp,Yasp : Word);
-
Description
Sets the aspect ratio of the
current screen to Xasp/Yasp.
-
Errors
- None
-
See also
- InitGraph, GetAspectRatio
8.4.63 SetBkColor
-
Declaration
- Procedure SetBkColor (Color : Word);
-
Description
Sets the background color to
Color.
-
Errors
- None.
-
See also
- GetBkColor, SetColor
8.4.64 SetColor
-
Declaration
- Procedure SetColor (Color : Word);
-
Description
Sets the foreground color to
Color.
-
Errors
- None.
-
See also
- GetColor, SetBkColor
8.4.65 SetFillPattern
-
Declaration
- Procedure SetFillPattern (FillPattern : FillPatternType,
Color : Word);
-
Description
- SetFillPattern
sets the current fill-pattern to FillPattern, and
the filling color to Color
The pattern is an 8x8 raster, corresponding to the 64 bits in
FillPattern.
-
Errors
- None
-
See also
- GetFillPattern, SetFillStyle
8.4.66 SetFillStyle
-
Declaration
- Procedure SetFillStyle (Pattern,Color : word);
-
Description
- SetFillStyle
sets the filling pattern and color to one of the
predefined filling patterns. Pattern can be one of the following predefined
constants :
- EmptyFill Uses backgroundcolor.
- SolidFill Uses filling color
- LineFill Fills with horizontal lines.
- ltSlashFill Fills with lines from left-under to top-right.
- SlashFill Idem as previous, thick lines.
- BkSlashFill Fills with thick lines from left-Top to bottom-right.
- LtBkSlashFill Idem as previous, normal lines.
- HatchFill Fills with a hatch-like pattern.
- XHatchFill Fills with a hatch pattern, rotated 45 degrees.
- InterLeaveFill
- WideDotFill Fills with dots, wide spacing.
- CloseDotFill Fills with dots, narrow spacing.
- UserFill Fills with a user-defined pattern.
-
Errors
- None.
-
See also
- SetFillPattern
8.4.67 SetGraphBufSize
-
Declaration
- Procedure SetGraphBufSize (BufSize : Word);
-
Description
- SetGraphBufSize
is a dummy function which does not do
anything; it is no longer needed.
-
Errors
- None.
-
See also
8.4.68 SetGraphMode
-
Declaration
- Procedure SetGraphMode (Mode : Integer);
-
Description
- SetGraphMode
sets the graphical mode and clears the screen.
-
Errors
- None.
-
See also
- InitGraph
8.4.69 SetLineStyle
-
Declaration
- Procedure SetLineStyle (LineStyle,Pattern,Width :
Word);
-
Description
- SetLineStyle
sets the drawing style for lines. You can specify a LineStyle which is
one of the following pre-defined constants:
- Solidln=0; draws a solid line.
- Dottedln=1; Draws a dotted line.
- Centerln=2; draws a non-broken centered line.
- Dashedln=3; draws a dashed line.
- UserBitln=4; Draws a User-defined bit pattern.
If UserBitln is specified then Pattern contains the bit pattern.
In all another cases, Pattern is ignored. The parameter Width
indicates how thick the line should be. You can specify one of the following
pre-defined constants:
-
Errors
- None.
-
See also
- GetLineSettings
8.4.70 SetPalette
-
Declaration
- Procedure SetPalette (ColorNr : Word; NewColor : ShortInt);
-
Description
- SetPalette
changes the ColorNr-th entry in the palette to
NewColor
-
Errors
- None.
-
See also
- SetAllPallette,SetRGBPalette
8.4.71 SetRGBPalette
-
Declaration
- Procedure SetRGBPalette (ColorNr,Red,Green,Blue : Integer);
-
Description
- SetRGBPalette
sets the ColorNr-th entry in the palette to the
color with RGB-values Red, Green Blue.
-
Errors
- None.
-
See also
- SetAllPallette,
SetPalette
8.4.72 SetTextJustify
-
Declaration
- Procedure SetTextJustify (Horizontal,Vertical : Word);
-
Description
- SetTextJustify
controls the placement of new text, relative to the
(graphical) cursor position. Horizontal controls horizontal placement, and can be
one of the following pre-defined constants:
- LeftText=0; Text is set left of the pointer.
- CenterText=1; Text is set centered horizontally on the pointer.
- RightText=2; Text is set to the right of the pointer.
Vertical controls the vertical placement of the text, relative to the
(graphical) cursor position. Its value can be one of the following
pre-defined constants :
- BottomText=0; Text is placed under the pointer.
- CenterText=1; Text is placed centered vertically on the pointer.
- TopText=2;Text is placed above the pointer.
-
Errors
- None.
-
See also
- OutText, OutTextXY
8.4.73 SetTextStyle
-
Declaration
- Procedure SetTextStyle (Font,Direction,Magnitude : Word);
-
Description
- SetTextStyle
controls the style of text to be put on the screen.
pre-defined constants for Font are:
- DefaultFont=0;
- TriplexFont=2;
- SmallFont=2;
- SansSerifFont=3;
- GothicFont=4;
Pre-defined constants for Direction are :
-
Errors
- None.
-
See also
- GetTextSettings
8.4.74 SetUserCharSize
-
Declaration
- Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
-
Description
Sets the width and height of vector-fonts. The horizontal size is given
by Xasp1/Xasp2, and the vertical size by Yasp1/Yasp2.
-
Errors
- None.
-
See also
- SetTextStyle
8.4.75 SetViewPort
-
Declaration
- Procedure SetViewPort (X1,Y1,X2,Y2 : Integer; Clip : Boolean);
-
Description
Sets the current graphical viewport (window) to the rectangle defined by
the top-left corner (X1,Y1) and the bottom-right corner (X2,Y2).
If Clip is true, anything drawn outside the viewport (window) will be
clipped (i.e. not drawn). Coordinates specified after this call are relative
to the top-left corner of the viewport.
-
Errors
- None.
-
See also
- GetViewSettings
8.4.76 SetVisualPage
-
Declaration
- Procedure SetVisualPage (Page : Word);
-
Description
- SetVisualPage
sets the video page to page number Page.
-
Errors
- None
-
See also
- SetActivePage
8.4.77 SetWriteMode
-
Declaration
- Procedure SetWriteMode (Mode : Integer);
-
Description
- SetWriteMode
controls the drawing of lines on the screen. It controls
the binary operation used when drawing lines on the screen. Mode can
be one of the following pre-defined constants:
-
Errors
- None.
-
See also
8.4.78 TextHeight
-
Declaration
- Function TextHeight (S : String) : Word;
-
Description
- TextHeight
returns the height (in pixels) of the string S in
the current font and text-size.
-
Errors
- None.
-
See also
- TextWidth
8.4.79 TextWidth
-
Declaration
- Function TextWidth (S : String) : Word;
-
Description
- TextHeight
returns the width (in pixels) of the string S in
the current font and text-size.
-
Errors
- None.
-
See also
- TextHeight
In what follows we describe some things that are different on the various
platforms:
root
2000-12-20