This blog is under construction

Wednesday, 11 September 2013

fillellipse example in C

Header file:
    graphics.h

Synopsis:
     void fillellipse (int x, int y, int stangle, int endangle,
                      int xradius, int yradius);
     (x, y) - center of the ellipse
     stangle - starting angle
     endangle - ending angle
     xradius - radius of ellipse at x-axis
     yradius - radius of ellipse at y-axis

Description:
      fillellipse() draws an ellipse with current drawing color, then fills it with current fill pattern and current fill color.


fillellipse function in c graphics



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

  int main(void) {
        /* request autodetection */
        int graphicDriver = DETECT, graphicMode, err;
        int i, x, y, xRad = 240, yRad = 165;

        /* 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));
                return 0;
        }

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

        /* loop through the fill patterns */
        for (i = EMPTY_FILL; i < USER_FILL; i++) {
                /* set fill pattern */
                setcolor(i % 12);
                setfillstyle(i, i % 12);

                /* draw a filled ellipse */
                fillellipse(x, y, xRad, yRad);
                xRad = xRad - 15;
                yRad = yRad - 10;

                /* sleep for 300 milliseconds */
                delay(300);
        }

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




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




No comments:

Post a Comment