This blog is under construction

Sunday, 8 September 2013

Pie chart - Animation using C graphics

Implement pie chart using C graphics


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

  int main() {
        /* request auto detection */
        int gdriver = DETECT, gmode, err;
        int midx, midy;
        char str[64];

        /* initialize graphic mode */
        initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
        err = graphresult();

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

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

        /* pie slice representing safari */
        delay(100);
        setcolor(YELLOW);
        setfillstyle(CLOSE_DOT_FILL, YELLOW);
        pieslice(midx, midy, 0, 40, 100);

        /* pie slice representing firefox */
        delay(100);
        setcolor(LIGHTRED);
        setfillstyle(LINE_FILL, LIGHTRED);
        pieslice(midx, midy, 45, 140, 100);

        /* pie slice representing opera */
        delay(100);
        setcolor(CYAN);
        setfillstyle(WIDE_DOT_FILL, CYAN);
        pieslice(midx, midy, 145, 200, 100);

        /* pie slice representing chrome */
        delay(100);
        setcolor(LIGHTMAGENTA);
        setfillstyle(SLASH_FILL, LIGHTMAGENTA);
        pieslice(midx, midy, 205, 300, 100);

        /* pie slice representing internet explorer */
        delay(100);
        setcolor(LIGHTGREEN);
        setfillstyle(BKSLASH_FILL, LIGHTGREEN);
        pieslice(midx, midy, 305, 355, 100);

        /* naming pie slice with corresponding names */
        delay(100);
        setcolor(WHITE);
        settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
        settextjustify(CENTER_TEXT, CENTER_TEXT);
        sprintf(str, "%s", "SAFARI");
        moveto(midx + 140, midy - 40);
        outtext(str);

        delay(100);
        sprintf(str, "%s", "FIREFOX");
        moveto(midx, midy - 130);
        outtext(str);

        delay(100);
        sprintf(str, "%s", "OPERA");
        moveto(midx - 140, midy);
        outtext(str);

        delay(100);
        sprintf(str, "%s", "CHROME");
        moveto(midx - 20, midy + 110);
        outtext(str);

        delay(100);
        sprintf(str, "%s", "IE");
        moveto(midx + 120, midy + 40);
        outtext(str);

        /* pie chart for various browsers */
        delay(100);
        setcolor(YELLOW);
        sprintf(str, "%s", "PIE CHART FOR BROWSERS");
        moveto(75, midy);
        settextjustify(CENTER_TEXT, CENTER_TEXT);
        settextstyle(TRIPLEX_FONT, VERT_DIR, 3);
        outtext(str);

        getch();

        /* deallocate memory allocated for graphic screen */
        closegraph();
        return 0;
  }





Output: (Animate pie chart using c graphics)


2 comments:

  1. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    Data Science Interview Questions

    Angular JS Interview Questions

    Big Data Training in Velachery

    AWS Certified Developer

    Best Resource of Learning Devops

    Blueprism Interview Questions

    Automation Anywhere Interview Questions

    ReplyDelete
  2. Thats really great blog , thanks for sharing to us.
    Get all type digital machine like as AM.CO.ZA V-Series™ High-Pressure High-Speed USB Vinyl Cutters Vinyl Cutter

    ReplyDelete