Professional Documents
Culture Documents
Introduction To C++ Graphics
Introduction To C++ Graphics
functions of graphics.h
• C graphics using graphics.h functions can be used
to draw different shapes, display text in different
fonts, change colors and many more.
• points
• lines and line segments
• planes
• circles and ellipses
• triangles and other polygons
• spline curves
The C++ graphics plane
(0,0) X plane
Y plane
InitGraph
• InitGraph initializes the graph package.
Implementations
• Declaration :- void line(int x1, int y1, int x2, int y2);
// program draws a line from (100, 100) to (200, 200).
#include<graphics.h>
#include<conio.h>
main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
#include<graphics.h>
#include<conio.h>
main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
circle(100, 100, 50);
getch();
closegraph();
return 0;
}
rectangle function
• Declaration :- void rectangle(int left, int top, int
right, int bottom);