This blog is under construction

Wednesday 11 September 2013

getcolor example in c

Header file:
    graphics.h

Synopsis:
      int getcolor (void);
     
Description:
     getcolor() returns the current drawing color.



getcolor function in c graphics



  #include <graphics.h>
  #include <stdlib.h>
  #include <string.h>
  #include <stdio.h>
  #include <conio.h>

  int main(void) {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err, color, midx, midy;
        char str[35];

        /* initialize graphics and local variables */
        initgraph(&graphicDriver, &graphicMode,
                                "C:/TURBOC3/BGI");

        /* read result of initialization */
        err = graphresult();

        if (err != grOk) {
                printf("Graphics error: %s\n",
                                grapherrormsg(err));
                return 0;
        }

        midx = getmaxx() / 2;
        midy = getmaxy() / 2;
        setcolor(12);

        circle(midx, midy, 100);

        /* get the current drawing color */
        color = getcolor();

        sprintf(str, "color code for current drawing "
                                        "color is %d", color);

        /* display a message */
        outtextxy(20, 20, str);

        /* clean up */
        getch();
        closegraph();
        return 0;
  }





Output: (getcolor built-in function in c graphics.h)


No comments:

Post a Comment