#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<graphics.h>
#include<conio.h>
#include<malloc.h>
#define timedelay 20
using namespace std;
int xy[800][2];
void getpoints(int ,int ,int ,int );
int main()
{
initwindow(800,600,"Vishal Grade");
label1:
for(;;)
{
static int a=abs((rand()%(700)+500));
static int b= abs((rand()%(500)+500));
int c= abs((rand()%(700)+50));
int d= abs((rand()%(500)+50));
xy[0][0]=a;
xy[0][1]=b;
getpoints(a,b,c,d);
int s=rand()%15;
for(int i=0;i<c-a;i++)
{
cout<<xy[i][0]<<"\t"<<xy[i][1]<<endl;
if(50<=xy[i][0] &&xy[i][0]<=750 && 50<=xy[i][1] && xy[i][1]<=550)
{
for(int j=0;j<50;j++)
{
circle(xy[i][0],xy[i][1],j);
circle(xy[i][0],xy[i][1],50-j);
setcolor(rand()%10+5);
}
setcolor(rand()%10+5);
setbkcolor(s); //background color
delay(timedelay);
}
else {
delay(timedelay*3);
goto label1;
}
putpixel(xy[i][0],xy[i][1],3);
cleardevice();
}
a=c;
b=d;
}
getch();
}
void getpoints(int x1,int y1,int x2,int y2)
{
float m=float(y2-y1)/(x2-x1);
if(x1<=x2)
{
{
float y0;
int x0=1;
int step=x2-x1;
y0=m;
int i=1;
static float t=xy[0][1];
while(i<=step)
{
xy[i][0]=xy[i-1][0]+x0;
t=t+y0;
xy[i][1]=int(round(t));
i++;
}}
}
else
{
int y0;
float x0;
if(m<=0)
{
x0=1/m;
y0=1;
}
else
{
x0=-1/m;
y0=-1;
}
int step=y2-y1;
int i=1;
static float t=xy[0][0];
while(i<=step)
{
t=t+x0;
xy[i][0]=int(round(t));
xy[i][1]=xy[i-1][1]+y0;
i++;
}
}
}