Saturday, 10 February 2018

Animated circle c graphics






/*==============================
     Girfa Student Help
     Program : Animated circle
     More Program :http://girfahelp.blogspot.in/p/graphics-c-language.html
================================*/

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;
   int radius = 100;

   int i,j;
   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   setcolor(getmaxcolor());
   for(i=1,j=1;i<=200;i+=2)
   {
     setcolor(j++);
     circle(j, midy,i);
     if(j==10)
          j=1;
     delay(30);
   }
   for(i=1,j=1;i<=200;i+=2)
   {
     setcolor(j++);
     circle(midx,getmaxy()-1,i);
     if(j==10)
          j=1;
     delay(20);
   }
   for(i=1,j=1;i<=200;i+=2)
   {
     setcolor(j++);
     circle(getmaxx(), midy,i);
     if(j==10)
          j=1;
     delay(20);
   }
   for(i=1,j=1;i<=200;i+=2)
   {
     setcolor(j++);
     circle(midx,0,i);
     if(j==10)
          j=1;
     delay(20);

   }
   settextstyle(4,0,3);
   outtextxy(midx-52,midy-10,"Girfa Student Help");

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