Computer Graphics Lab Day-1: Here
Computer Graphics Lab Day-1: Here
Day-1
gd = graphdriver;
gm = graphmode;
initgraph
initgraph is used to initialize the graphics system by loading a graphics driver from disk and
thereby putting the system into graphics mode.
To start the graphics system, we first call the initgraph function. initgraph may use a particular
graphics driver and mode, or it may auto-detect and pick the corresponding driver at runtime,
according to our needs.
If we tell initgraph to autodetect, it calls detectgraph to select a graphics driver and mode. It also
resets all graphics settings to their defaults values like current position, color, viewport and so on
and also resets graph result to 0.
pathtodriver
pathtodriver denotes the directory path where initgraph must look for graphic drivers. initgraph
first goes through the directed path to look for the files and if they are not found there, it goes to
the current directory. The graphic driver must files must be present in the current directory if the
pathtodriver is null.
Computer Graphics Lab
Day-1
graphdriver
*graphdriver is the integer that specifies which graphics driver is to be used. We can give it a value
using a constant of the graphics_drivers enum type, which is defined in graphics.h and listed below.
graphmode
graphdriver and graphmode must be given proper values from the tables or we will get absurd and
unexpected results. The exception here is when graphdriver = DETECT. In this case, initgraph sets
*graphmode to the highest resolution available for the detected driver.
Explanation :The header file graphics.h contains line() function which is described below :
Declaration : void line(int x1, int y1, int x2, int y2);
line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2)
are end points of the line.
Examples:
Explanation :The header file graphics.h contains ellipse() function which is described below :
void ellipse(int x, int y, int start_angle, int end_angle, int x_radius, int y_radius)
In this function x, y is the location of the ellipse. x_radius and y_radius decide the radius of form
x and y.
start_angle is the starting point of angle and end_angle is the ending point of angle. The value of
angle can vary from 0 to 360 degree
Examples:
Syntax :
circle(x, y, radius);
where,
(x, y) is center of the circle.
'radius' is the Radius of the circle.
Examples :
Syntax :
Examples :