
Advanced Graphics Statments
There are many other graphics procedures and functions, which do not draw graphic objects, but manipulate the format of the graphic objects you draw. For example, if I want to fill a circle with a colour, it's like this:
Circle(GetMaxX Div 2, GetMaxY Div 2, 60); FillEllipse(GetMaxX Div 2, GetMaxY Div 2, 60, 60); {Note the radii}
The command 'FillEllipse' will fill the circle with the current colour. Take a look at the table below:
|
Statement Description Example |
SetFillStyle(Pattern, Colour); Changes the style of the filling of an object. It can only be used with bar/bar3d and pieslice. It has 13 different fill styles. SetFillStyle(XHatchFill,LightCyan); |
OR |
SetFillStyle(10,3); |
SetUserCharSize(MultX, DivX, MultY, DivY); Display the text in a larger or smaller size. SetUserCharSize(5,1,3,1); |
SetTextStyle(Font, Direction, Size); Display text using the font style, orientation and size indicated as shown. SetTextStyle(TriplexFont, HorizDir,2); |
ClearViewPort; Clears the active screen page. ClearViewPort; |
GetDriverName Get the driver name being currently used. OutText('Using driver:' + GetDriverName); |
|
It is useful to try to run the program below yourself so as to understand the meaning of several reserved words included in certain functions, such as:
SetTextStyle(SansSerifFont,VertDir,2);
OR
Bar3D(40,50,60,100,50,TopOn);
Program Lesson8_Program3;
Uses Graph;
Var Gd, Gm: Integer;
Begin
Gd := Detect;
InitGraph(Gd, Gm, ' ');
if GraphResult <> grOk then Halt(1);
SetTextStyle(TriplexFont, HorizDir, 1);
SetUserCharSize(2,1,10,1);
SetTextJustify(CenterText, CenterText);
OutTextXY(GetMaxX Div 2,200,'Is it big enough?');
readln;
ClearViewPort;
SetTextStyle(SmallFont, VertDir, 5);
SetTextJustify(LeftText,CenterText);
OutTextXY(200,250,'VertDir (vertical) Direction.
Do you understand now??');
Readln;
ClearViewPort;
Bar3d(150,80,450,330,50,TopOn);
SetTextStyle(SansSerifFont, HorizDir, 2);
SetColor(LightRed);
OutTextXY(130,410,'BAR3D(150,80,350,330,50,TopOn);');
Readln;
ClearViewPort;
Bar3d(150,80,450,330,50,TopOff);
SetColor(LightGreen);
OutTextXY(130,410,'BAR3D(150,80,450,330,50,TopOff);');
Readln;
ClearViewPort;
OutTextXY(130,380,'SetFillStyle(BkSlashFill,7);');
SetFillStyle(BkSlashFill,7);
Bar3d(150,80,450,330,50,TopOn);
OutTextXY(130,410,'BAR3D(150,80,450,330,50,TopOn);');
Readln;
ClearViewPort;
OutTextXY(130,380,'SetFillStyle(XHatchFill,6);');
SetFillStyle(XHatchFill,6);
Bar3d(150,80,450,330,50,TopOn);
OutTextXY(130,410,'BAR3D(150,80,450,330,50,TopOn);');
Readln;
CloseGraph;
End.
This is just the beginning of the graphics adventure. If you would like to be a guru in graphics, just keep on practicing and produce only graphical programs.
Next Lesson [Lesson9]: File Handling
Comments are no longer accepted due to a defeated battle against an overwhelimg amounts of incoming spam! Apologies for any inconvenience.
[HOME][LESSON INDEX][INVITE A FRIEND][FORUM][ABOUT ME]