This blog is under construction

Saturday, 14 September 2013

setvisualpage example in c

Header file:
    graphics.h

Synopsis:
      void setvisualpage(int page);
     
Description:
     setvisualpage() sets the visual graphics page number.


setvisualpage function in c graphics



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

  int main(void) {
        /* select a driver and mode that supports multiple pages. */
        int graphicDriver = EGA, graphicMode = EGAHI;
        int err, midx, midy;

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

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

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

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


        /*  select the off screen page for drawing */
        setactivepage(1);

        /* output a message on page #1 */
        settextjustify(CENTER_TEXT, CENTER_TEXT);
        outtextxy(midx, 50, "Here is page 1");

        /* draws a circle using the current drawing color */
        setcolor(10);
        setfillstyle(SOLID_FILL, 10);
        circle(midx, midy, 150);
        floodfill(midx, midy, 10);

        /* select drawing to page #0 */
        setactivepage(0);

        /* output a message  on page #0 */
        outtextxy(midx, midy, "Here is page 0.");
        outtextxy(midx, midy+textheight("W"),
                        "Press any key to view page 1:");
        getch();

        /* select page #1 as the visible page */
        setvisualpage(1);

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





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


No comments:

Post a Comment