Basic Graph Functions

 

1) INITGRAPH

  • Initializes the graphics system.
  • Initgraph initializes the graphic 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.

Declaration

void far initgraph(int far *graphdriver)

 

2) GETPIXEL, PUTPIXEL

  • Getpixel gets the color of a specified pixel.
  • Putpixel places a pixel at a specified point.

Declaration

unsigned far getpixel(int x, int y)

void far putpixel(int x, int y, int color)

 

3) CLOSE GRAPH

  • Shuts down the graphic system.
  • Close graph deallocates all memory allocated by the graphic system.
  • It then restores the screen to the mode it was in before you called initgraph.

Declaration

void far closegraph(void);

 

4) ARC, CIRCLE

  • Arc draws a circular arc in the current drawing color
  • Circle draws a circle in the current drawing color

Declaration

void far arc(int x, int y, int stangle, int endangle, int radius);

void far circle(int x, int y, int radius);

void far pieslice(int x, int y, int stangle, int endangle, int radius);

 

5) ELLIPSE, FILLELIPSE, SECTOR

  • ellipse draws an elliptical arc in the current drawing color.
  • fillellipse draws an elliptical arc in the current drawing color and then fills it with fill color and fill pattern.
  • sector draws an elliptical pie slice in the current drawing color and then fills it using the pattern and color defined by setfillstyle or setfillpattern.

Declaration

void far ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius)

void far fillellipse(int x, int y, int xradius, int yradius)

void farsectoe(int x, int y, int stangle, int endangle, int xradius, int yradius)

 

6) FLOODFILL

  • Floodfills an enclosed area on bitmap device.
  • The area bounded by the color border is flooded with the current fill pattern and fill color.

Declaration

void far floodfill(int x, int y, int border)

 

7) GETCOLOR, SETCOLOR

  • Getcolor returns the current drawing color.
  • Setcolor sets the current drawing color to color, which can range from 0 to getmaxcolor.
  • To set a drawing color with setcolor , you can pass either the color number or the
  • equivalent color name.

Declaration

int far getcolor(void);

void far setcolor(int color)

 

8) LINE,LINETO

  • Line draws a line from (x1, y1) to (x2, y2) using the current color, line style and thickness.
  • It does not update the current position (CP).
  • Lineto draws a line from the CP to (x, y), then moves the CP to (x,y).

 

Declaration

void far lineto(int x, int y)

 

9) RECTANGLE

  • It draws a rectangle in the current line style, thickness and drawing color.
  • (left, top) is the upper left corner of the rectangle, and (right, bottom) is its lower right corner.

Declaration

void far rectangle(int left, int top, int right, int bottom)

 

Leave a Reply

Your email address will not be published. Required fields are marked *