This blog is under construction

Monday 9 September 2013

arc example in C

Header file:
    graphics.h

Synopsis:
     void arc (int x, int y, int startangle, int endangle, int radius);
     (x, y)        - Center position of arc
     startangle  - start angle in degrees
     endangle    - end angle in degrees
     radius        - radius of the arc

Description:
      arc() draws a circular arc for the given angle centered at (x, y)


arc function in c graphics



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

  int main(void)  {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int code, i, x, y, radius = 0;
        int startAngle = 90, endAngle = 180;

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

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

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

        x = getmaxx();
        y = getmaxy();

        setcolor(getmaxcolor());
        for (i = 0; i < 100; i++) {
                /* draw arc */
                radius = radius + 10;
                arc(x, y, startAngle, endAngle, radius);
                delay(150);
        }

        /* clean up */
        getch();

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




Output: (arc function in c graphics)


No comments:

Post a Comment