Wednesday, 19 February 2014

ROTATING LINE



/**************************************************************************/
#include<math.h>
#include<stdio.h>
#include<conio.h>
#include<graphics.h>

void drawRevolvingLine(int,int,int);

int main()
{
                int gdriver=DETECT,gmode;
                int x,y,r;
                x=200;
                y=200;
                r=100;
                initgraph(&gdriver,&gmode,"");
                drawRevolvingLine(x,y,r);
                getch();
                return 0;

}

void drawRevolvingLine(int x,int y,int r)
{
                int i;
                int nx,ny;
                double rad;
                int cnx,cny;

                for(i=0;i<=360 && !kbhit();i++)
                {
                                rad=i*(180.0)/3.14;
                                nx=(int)(x+r*cos(rad));
                                ny=(int)(y+r*sin(rad));

                                {cnx=(int)(nx+r*cos(rad));
                                cny=(int)(ny+r*sin(rad));
                                line(nx,ny,cnx,cny);

                                delay(100);
                                cleardevice();
                                }
                                cleardevice();
                }

}
/****************************************************************************/

No comments:

Post a Comment