2. Graphics
It is used to create different
shapes in different colours.
2Computer Science Department
.
3. Requirements
IT requires a graphics monitor, and also graphics
card such as VGA, SVGA, EGA.
Graphics includes:
• Lines in different colors and styles.
• Different shapes like circles, rectangles in different
styles.
• Text in different fonts, sizes, and style.
3Computer Science Department
4. Files needed with C++ compiler to work in Graphics
• The header file “graphics.h” it contains built-in graphic
functions.
• Borland Graphics Interface (BGI) files. These files
contain graphics driver programs that initialize the
computer monitor into graphics mode.
• BGI files have BGI extension.
4Computer science Department
6. Text Mode
In text mode only text can be displayed .
The images and the other graphics can not be displayed.
6Computer Science Department
7. Graphics Mode
• Images and other graphics can be displayed.
• The output is displayed on the computer
screen in points or pixels.
8. VGA Monitor
In the VGA monitor, the screen is divided into
480 rows and 640 columns of dots. Thus the
VGA monitor screen is divided into 640x480
pixels. The number of dots per inch is called
resolution of the screen
10. Initialization of Graphics Mode
initigraph () it is used to initialize the display
into a graph mode.
Syntax:
initigraph (&driver, &mode," path”);
11. Driver
• It must be install in computer.
• It may be an integer variable or an integer
constant identifier.
Like CGA, EGA, SVGA.
It is automatically detected by using keyword
“DETECT”.
int driver, mode;
Driver=DETECT;
12. Mode
• It represents output resolution on the
computer screen.
• The normal mode of VGA is VGAHI. It
gives high resolution.
13. &
• Represents the address of constant
numerical identifier.
• If constants (VGA,VGAHI) are used,
then this operator will not used.
Initgraph(VGA,VGAHI, “path”);
14. Path
• It represent the path of graphics drivers.
• It is the directory on the disk where BGI files
are located.
• BGI files are stored in “C:TCBGI”.
Intigraph(VGA,VGAHI, “C:TCBGI”);
18. Text in graphics Mode
Text can also be written in different
fonts, styles, sizes, colors and
directions.
19. “outtext” Function
It is used to print text on the computer
screen in graphics mode.
Syntax:
outtext(string);
String: it represents the characters.
it enclosed into a double quotes.
20. “moveto” Functions
It is used to move the current cursor position to the
specified location on the screen where output is to
be print.
It is similar to “gotoxy” function used in text mode.
Syntax:
moveto(x, y);
x and y are co-ordinates.
21. “outtextxy” Function
• It is similar to the “outtext” function but it is
used to print text on the screen at the
specified location.
• It serves the purpose of both the “moveto”
and “outtext” functions.
Syntax:
outtext(x,y,string);
22. “Settextstyle” Function
• It is used to define the text style in a
graph mode.
• Text style includes the font type, font
size and the text direction.
Syntax:
Settextstyle(style, dir, size);
24. “setcolor” Function
• It is used to define color of the object and
the text in graphics mode.
Syntax:
Setcolor(co);
• co: represent the color.
Its value from 0-15, it may also be numerical
constant identifier, like BLUE,GREEN etc…
25. “setbkcolor” Function
• It is used to define the background
color of the screen.
Syntax:
setbkcolor(co);
26. Creating Objects in Graphics Mode
Different objects like lines, circles,
rectangles and many other shapes are
created in graph mode using various
built-in functions.
28. “arc” Function
It is used to draw a circular arc starting
from a specified angle and up to
another specified angle.
Syntax:
arc(x,y,stangle,endangle,radius)
• All parameters are of int types.
30. “rectangle” Function
• It is used to draw a rectangle between
two points.
Syntax:
rectangle(x1,y1,x2,y2);
31. “setlinestyle” Function
• It is used to set the line style of different
objects that are drawn.
• The lines objects can be drawn in different
styles, patterns and thickness.
Syntax:
setlinestyle(style, pattern, thickness);