Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 14. Graphics > Few Graphics Functions

14.3. Few Graphics Functions

  1. initgraph();

    This function initializes the graphics system. Prototype is defined in "graphics.h". It is declared as given below:

    void far initgraph(int far *gd, int far *gm, char far *pathtodriver);

    where gd is graphics driver and gm is graphics mode.

    In real application to detect graphics drives DETECT macro is used.

  2. closegraph();

    This function shuts down the graphics system. The declaration is as under. Prototype is defined in "graphics.h".

    void far closegraph(void);
  3. restorecrtmode();

    This function restores the screen mode to its pre-initgraph setting. Its prototype is defined in "graphics.h".

    void far restorecrtmode(void);
  4. graphresult();

    This function returns an error code for the last failed graphics operation. This function is defined as under.

    int far graphresult(void);

    Returns the error code for the last graphics execution that reported an error and resets the error level to grOK, where grOK is an enumerated error code.

  5. getmaxx(); and getmaxy();

    The getmaxx() returns maximum ‘x’ screen coordinate and getmaxy() returns maximum y’ screen coordinate. Its prototype is defined in "graphics.h". These functions can be declared as under.

    int far getmaxx(void);
    int far getmaxy(void);
  6. line();

    Draws a line between two specified points. This function is declared as under.

    void far line(int x1, int y1, int x2, int y2);

    Draws a line from (x1, y1) to (x2, y2) using the current color, line style and thickness.

  7. circle();

    This function draws a circle at (x, y) of the given radius. This function is declared as under.

    void far circle(int x, int y, int radius);
  8. arc();

    This function draws an arc. This function is declared as under.

    void far arc(int x, int y, int sa, int ea, int r);

    where (x, y) is the centre point. The variables sa and ea are the start and end angles in degrees and variable r is the radius.

  9. ellipse();

    This function draws an elliptical arc. This function is declared as under.

    void far ellipse(int x, int y, int sa, int ea, int xr, int yr);

    where (x, y) is the centre point. The variables sa and ea are start and end angles in degrees, respectively. The variables xr and yr are horizontal and vertical radii.

  10. bar();

    This function draws a bar using given coordinates. This function can be declared as under.

    void far bar(int left, int top, int right, int bottom);
  11. setcolor();

    This function sets the current drawing color. This is declared as under.

    void far setcolor(int color);
  12. outtextxy();

    Displays a string at the specified location (graphics mode). This function is declared as given under.

    void far outtextxy(int x, int y, char far *textstring);
  13. settextstyle();

    This function sets the current text attributes. This function is declared as under.

    void far settextstyle(int font, int direction, int fontsize);
  14. settextjustify();

    This function sets text justification for graphics mode. This function is declared as given below.

    void far settextjustify(int horiz, int vert);

    Affects text output with outtext() function, etc. Text is justified horizontally and vertically.

  15. getcolor();

    Returns the current drawing color. This function is declared as follows.

    void far getcolor(void);

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint