Basic Graphics Function:


INITGRAPH: - Initializes the graphics system
void far initgraph (int far *graphdriver, int far *graphmode, char far *pathtodriver);
To start the graphics system, you must first call initgraph. initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode. initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their defaults, then resets graphresult to 0.

*graphdriver: - Integer that specifies the graphics driver to be used. You can give graphdriver avalue using a constant of the graphics drivers enumeration type.

*graphmode:- Integer that specifies the initial graphics mode (unless *graphdriver = DETECT).
If *graphdriver = DETECT, initgraph sets *graphmode to the highest resolution available for the detected driver. You can give *graphmode a value using a constant of thegraphics_modes enumeration type.

*pathtodriver: - Specifies the directory path where initgraph looks for graphics drivers (*.BGI) first.
a. If they’re not there, initgraph looks in the current directory.
b. If pathtodriver is null, the driver files must be in the current directory. This is also the path settextstyle searches for the stroked
character font files (*.CHR).

GETPIXEL, PUTPIXEL :-
intgetpixel(int x, int y);
voidputpixel(int x, int y, int color);
getpixel returns the color of pixel present at point(x, y).
putpixel plots a pixel at a point(x, y) of specified color.

CLOSE GRAPH :-.
Void far closegraph(void):- Close graph deallocates all memory allocated by the graphics system. It then restores the screen to the mode it was in before you called initgraph.
Following are inbuilt functions of graphics library used for assignment:-

rectangle():- It draws a rectangle in the current line style, thickness, and drawing
color.void rectangle(int left, int top, int right, int bottom);

ellipse():- It draws an elliptical arc in the current drawing color.
void ellipse(int x, int y, intstangle, intendangle, intxradius, intyradius);

sector():- It draws and fills an elliptical pie
void sector(int x, int y, intstangle, intendangle, intxradius, intyradius);

Line ():- Line () is used to draw a line.
Line(x1,y1,x2,y2);

Circle(): is used to draw the circle.
Syntax: circle(x1,y1,radius);

drawpoly ():- draws the outline of a polygon, draws a polygon using the current line style and color.

Drawpoly(numpoints,*polypoints); 
Numpoints:- specifies number of points
*polypoints :- points to a sequence of (numpoints*2) integers.

Outtext: -Display a string in the viewport
Void far outtext(char far textstring);
Example: - outtext(display text in graphics);

Putpixel: - plots a pixel at the specified point.
Syntax: void far putpixel (int x, inty,intpixelcolor);
Example:putpixel(100,100,15);

Closegraph: shuts down the graphics mode
Syntax: -void far close graph( void );
Example: - closegraph( );


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: