This blog is under construction

Thursday, 12 September 2013

getmaxcolor example in c

Header file:
    graphics.h

Synopsis:
      int getmaxcolor(void);
     
Description:
     getmaxcolor() returns highest possible color value.


getmaxcolor function in c graphics



  #include <stdio.h>
  #include <conio.h>
  #include <graphics.h>
  #include <dos.h>

  int main() {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int i, err, midx, midy, maxcolor;

        /* initialize graphics system */
        initgraph(&graphicDriver, &graphicMode, "C:/TURBOC3/BGI");
        err = graphresult();

        if (err != grOk) {
                /* error occurred */
                printf("Graphic Error: %s\n",
                                grapherrormsg(err));
                return 0;
        }

        /* mid value in x and y axis */
        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        /* sets justification for graphics mode */
        settextjustify(CENTER_TEXT, CENTER_TEXT);

        /* setting the font style */
        settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);

        /* get the highest possible valid color value */
        maxcolor = getmaxcolor();

        /* setting the current drawing color */
        setcolor(maxcolor);

        /* prints the text at the given position(midx, midy) */
        outtextxy(midx, midy, "Written in max color");

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





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


No comments:

Post a Comment