This blog is under construction

Thursday 12 September 2013

pieslice example in c

Header file:
    graphics.h

Synopsis:
      void pieslice (int x, int y, int stangle, int endangle, int radius);
     (x, y) - center position of pieslice
     stangle - starting angle
     endangle - ending angle
     radius - radius of the pieslice
     
Description:
     pieslice() draws and fill the pieslice using the current drawing color.


pieslice function in c graphics



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

  int main(void) {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err, midx, midy, radius = 75;

        /* 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 positions at x and y-axis */
        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        /* set fill style and draw a pie slice */
        setfillstyle(CLOSE_DOT_FILL, 10);
        pieslice(midx, midy, 20, 70, radius);
        pieslice(midx, midy, 110, 160, radius);
        pieslice(midx, midy, 200, 250, radius);
        pieslice(midx, midy, 290, 340, radius);

        /* draws a circle at the center position of the flower */
        setcolor(12);
        setfillstyle(SOLID_FILL, 12);
        circle(midx, midy, 5);
        floodfill(midx, midy, 12);

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





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


No comments:

Post a Comment