Wednesday, December 31, 2008

Boundary Fill Algorithm (Non Recursive)

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<process.h>
int fcolor,bcolor;
void dda(float x1,float y1,float x2,float y2)
 {
 float dx,dy,x=x1,y=y1,m;
 int i;
 dx=x2-x1;
 dy=y2-y1;
 if(abs(dx)>=abs(dy))
 m=abs(dx);
 else m=abs(dy);
 putpixel((int)x,(int)y,bcolor);
 for(i=1;i<=m;i++)
 {
  x=x+dx/m;
  y=y+dy/m;
  putpixel((int)x,(int)y,bcolor);
 }
 }
struct pix
{
int xc;
int yc;
};
struct pix stk[9999],currPix;
int top=-1;
int currcolor;
void push(int xi,int yi)
{
top++;
if(top>=9999)
{
printf("Stack overeflow..");
exit(0);
}
else
{
stk[top].xc=xi;
stk[top].yc=yi;

}

}
void pop()
{
if(top==-1)
{
printf("Stack underflow..");
exit(0);
}
else
{
currPix.xc=stk[top].xc;
currPix.yc=stk[top].yc;
top--;
}
}

void main()
{
int a;
int gd=DETECT,gm;
void bfill(int,int);
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("\nEnter fill color:");
scanf("%d",&fcolor);
printf("\nEnter boundary color:");
scanf("%d",&bcolor);
cleardevice();
setcolor(bcolor);
//circle(200,200,r);
dda(100,75,100,25);
   dda(100,25,200,25);
   dda(200,25,200,75);
   dda(200,75,100,75);

push(150,50);
bfill(150,50);
getch();
closegraph();

}
void bfill(int x ,int y)
{
int currcolor=getpixel(x,y);
while(top!=-1)
{
if(currcolor!=bcolor && currcolor!=fcolor)
{
delay(2);
setcolor(fcolor);
putpixel(x,y,fcolor);
push(x+1,y);
push(x-1,y);
push(x,y+1);
push(x,y-1);

}
pop();
x=currPix.xc;
y=currPix.yc;
currcolor=getpixel(x,y);
}
}

Light House : "Animation"

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

int xmid,ymid,xb,yb;
int a=300,b=120;

void initialize()
{
 int gd=DETECT,gm;
 initgraph(&gd,&gm,"c:\\tcc");
 cleardevice();
 xmid=getmaxx()/2;
 ymid=getmaxy()/2;
}

void ground()
{
 setcolor(LIGHTBLUE);
 line(0,ymid+100,640,ymid+100);
}

void lighthouse()
{
 setcolor(BROWN);
 line(xmid-40,ymid+99,xmid+40,ymid+99);
 line(xmid-25,ymid-100,xmid+25,ymid-100);
 line(xmid-40,ymid+99,xmid-25,ymid-100);
 line(xmid+40,ymid+99,xmid+25,ymid-100);
 rectangle(xmid-10,ymid-115,xmid+10,ymid-100);
}

void karakkam()
{
 int angle,x,y,c=0;
 float angle_rad;
 xb=xmid,yb=ymid-107;
 angle=0;
 while(!kbhit())
 {
  lighthouse();
  angle_rad=(3.14/180)*angle;

  //parametric equation of ellipse
  x=xb+a*cos(angle_rad);//a=xmajor
  y=yb-b*sin(angle_rad);//b=yminor

  setcolor(YELLOW);
  line(xb,yb,x,y);
  delay(30);
  if(c>=20)
  {
   lighthouse();
   angle_rad=(3.14/180)*(angle-20);
   x=xb+a*cos(angle_rad);
   y=yb-b*sin(angle_rad);
   setcolor(BLACK);
   line(xb,yb,x,y);
  }
  else
  c++;

  angle++;
 }
}

void main()
{
 initialize();
 ground();
 lighthouse();
 karakkam();
 getch();
 closegraph();
}

Tuesday, December 30, 2008

Flag : "Animation"

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<math.h>
int x,y,angle=0;
void main()
{
  int gd=DETECT,gm;
  initgraph(&gd,&gm,"c:\\tcpp\\bgi");

 for(x=100,y=200;x<400;x++,angle++)
 {
 setfillstyle(SOLID_FILL,RED);
 bar(50,180,55,500); //flag rod

 setcolor(WHITE);

 y=200+15*sin(angle*3.14/180);
 line(x/2,0,x/2,500);delay(200);

 setcolor(LIGHTRED);
 line(x/2,y,x/2,y+15);

 setcolor(WHITE);
 line(x/2,y+15,x/2,y+30);

 setcolor(GREEN);
 line(x/2,y+30,x/2,y+45);

 setcolor(0);
 delay(2);

 if((x==399)&&(angle<1000))
 {
  x=100;angle=angle+5;//cleardevice();
 }

 }
 getch();
 getch();
 }

BSpline Curve

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

struct point {
double x;
double y;
double z;
};

void compute_intervals(int *u, int n, int t);
double blend(int k, int t, int *u, double v);
void compute_point(int *u, int n, int t, double v, point *control,
point *output);

void bspline(int n, int t, point *control, point *output, int num_output)
{
int *u;
double increment,interval;
point calcxyz;
int output_index;

u=new int[n+t+1];
compute_intervals(u, n, t);

increment=(double) (n-t+2)/(num_output-1);
interval=0;

for (output_index=0; output_index<num_output-1; output_index++)
{
compute_point(u, n, t, interval, control, &calcxyz);
output[output_index].x = calcxyz.x;
output[output_index].y = calcxyz.y;
output[output_index].z = calcxyz.z;
interval=interval+increment;
}
output[num_output-1].x=control[n].x;
output[num_output-1].y=control[n].y;
output[num_output-1].z=control[n].z;

delete u;
}

void main()
{
int graphdriver = DETECT, graphmode, error_code;
initgraph(&graphdriver, &graphmode, "c:\\tc\\bgi");
int *u;
int n,t,i,x1,y1;
n=7;
t=4;
point *pts; // allocate our control point array
pts=new point[n+1];

pts[0].x=10; pts[0].y=100; pts[0].z=0;
pts[1].x=200; pts[1].y=100; pts[1].z=0;
pts[2].x=345; pts[2].y=300; pts[2].z=0;
pts[3].x=400; pts[3].y=250; pts[3].z=0;
pts[4].x=500; pts[4].y=450; pts[4].z=0;
pts[5].x=550; pts[5].y=150; pts[5].z=0;
pts[6].x=570; pts[6].y=50; pts[6].z=0;
pts[7].x=600; pts[7].y=100; pts[7].z=0;

int resolution = 500;
point *out_pts;
out_pts = new point[resolution];

bspline(n, t, pts, out_pts, resolution);

setcolor(10);
for (i=0; i<=n; i++)
circle(pts[i].x,pts[i].y,2);

circle(pts[0].x,pts[0].y,0);
for (i=0; i<resolution; i++)
{
setcolor(i);
putpixel(out_pts[i].x,out_pts[i].y,WHITE);delay(10);
}getch();
closegraph();
}

double blend(int k, int t, int *u, double v)
{
double value;

if (t==1)
{
if ((u[k]<=v) && (v<u[k+1]))
value=1;
else
value=0;
}
else
{
if ((u[k+t-1]==u[k]) && (u[k+t]==u[k+1])) // check for divide by zero
value = 0;
else
if (u[k+t-1]==u[k]) // if a term's denominator is zero,use just the other
value = (u[k+t] - v) / (u[k+t] - u[k+1]) * blend(k+1, t-1, u, v);
else
if (u[k+t]==u[k+1])
value = (v - u[k]) / (u[k+t-1] - u[k]) * blend(k, t-1, u, v);
else
value = (v - u[k]) / (u[k+t-1] - u[k]) * blend(k, t-1, u, v) +
(u[k+t] - v) / (u[k+t] - u[k+1]) * blend(k+1, t-1, u, v);
}
return value;
}

void compute_intervals(int *u, int n, int t) // figure out the knots
{
int j;

for (j=0; j<=n+t; j++)
{
if (j<t)
u[j]=0;
else
if ((t<=j) && (j<=n))
u[j]=j-t+1;
else
if (j>n)
u[j]=n-t+2; // if n-t=-2 then we're screwed, everything goes to 0
}
}

void compute_point(int *u, int n, int t, double v, point *control,
point *output)
{
int k;
double temp;

// initialize the variables that will hold our outputted point
output->x=0;
output->y=0;
output->z=0;

for (k=0; k<=n; k++)
{
temp = blend(k,t,u,v); // same blend is used for each dimension coordinate
output->x = output->x + (control[k]).x * temp;
output->y = output->y + (control[k]).y * temp;
output->z = output->z + (control[k]).z * temp;
}
}

Cohonen Sutherland Line Clipping

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#define TRUE 1
#define FALSE 0

typedef unsigned int outcode;
typedef unsigned char boolean;
struct point
{
 double x,y;
};
struct line
{
 struct point p1,p2;
};
enum{TOP = 0x1,BOTTOM = 0x2,RIGHT = 0x4,LEFT = 0x8};
outcode Compoutcode(double x, double y, double xmin, double xmax, double ymin, double ymax)
{
 outcode code = 0;
 if(y > ymax)
  code|=TOP;
 else
  if(y < ymin)
   code|=BOTTOM;
 if(x>xmax)
  code|=RIGHT;
 else
  if(x<xmin)
   code|=LEFT;
 return code;
}
void LineClipAndDraw(double x0,double y0,double x1,double y1,double xmin,double xmax,double ymin,double ymax)
{
 outcode outcode0,outcode1,outcodeOut;
 boolean accept = TRUE,done = FALSE;
 outcode0 = Compoutcode(x0,y0,xmin,xmax,ymin,ymax);
 outcode1 = Compoutcode(x1,y1,xmin,xmax,ymin,ymax);
 do
 {
  if(!(outcode0|outcode1))
  {
   accept = TRUE;
   done = TRUE;
  }
  else
   if(outcode0 & outcode1)
   {
    done = TRUE;
    accept = FALSE;
   }
   else
   {
    double x,y;
    outcodeOut = outcode0?outcode0:outcode1;
    if(outcodeOut&TOP)
    {
     x = x0+(x1-x0)*(ymax-y0)/(y1-y0);
     y = ymax;
    }
    else
     if(outcodeOut & BOTTOM)
     {
      x = x0 + (x1-x0)*(ymin-y0)/(y1-y0);
      y = ymin;
     }
     else
      if(outcodeOut & RIGHT)
      {
       y = y0 + (y1-y0)*(xmax-x0)/(x1-x0);
       x = xmax;
      }
      else
      {
       y = y0 + (y1 - y0)*(xmin - x0)/(x1-x0);
       x = xmin;
      }
      if(outcodeOut == outcode0)
      {
       x0 = x;
       y0 = y;
       outcode0 = Compoutcode(x0,y0,xmin,xmax,ymin,ymax);
      }
      else
      {
       x1 = x;
       y1 = y;
       outcode1 = Compoutcode(x1,y1,xmin,xmax,ymin,ymax);
      }
   }
 }while(done == FALSE);
 if(accept)
  line(x0,y0,x1,y1);
}

void main()
{
 int gmode = DETECT,gdriver;
 struct line lines[10];
 int n;
 double xmin,xmax;
 double ymin,ymax;
 double xscale,yscale;
 int i;
 initgraph(&gmode,&gdriver,"c:/tc/bgi");
 cout << "Enter the number of lines: ";
 cin >> n;
 cout << "Enter the endpoints of the lines: " << endl;
 for(i=0;i<n;i++)
 {
  cout <<"line "<< i+1 << ":\n";
  cout << "x1 : ";
  cin >> lines[i].p1.x;
  cout << "y1 : ";
  cin >> lines[i].p1.y;
  cout << "x2 : ";
  cin >> lines[i].p2.x;
  cout << "y2 : ";
  cin >> lines[i].p2.y;
  cout << endl;
 }
 cout << "Enter the Top Left of the clip window: "<< endl;
 cout << "X Axis : ";
 cin >> xmin;
 cout << "Y Axis : ";
 cin >> ymin;
 cout << "Enter the Bottom Right of the clip window: "<< endl;
 cout << "X axis : ";
 cin >> xmax;
 cout << "Y axis : ";
 cin >> ymax;
 cleardevice();
 for(i =0;i<n;i++)
  line(lines[i].p1.x,lines[i].p1.y,lines[i].p2.x,lines[i].p2.y);
 rectangle(xmin,ymin,xmax,ymax);
 getch();
 cleardevice();
 rectangle(xmin,ymin,xmax,ymax);
 for(i =0;i<n;i++)
  LineClipAndDraw(lines[i].p1.x, lines[i].p1.y, lines[i].p2.x, lines[i].p2.y, xmin, xmax, ymin, ymax);
 getch();
 closegraph();
}

Cohenen Sutherland Polygon Clipping Algorithm

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

void circl(int x, int y, int r)
{
int x1,y1,p;
x1=0;
y1=r;
p=3-2*r;

while(x1<y1)
    {
    plotcircle(x,y,x1,y1);
    if(p<0)
       p=p+4*x1+6;
    else
       {
       p=p+4*(x1-y1)+10;
       y1=y1-1;
       }
    x1=x1+1;
    }

if(x1==y1)
  plotcircle(x,y,x1,y1);
}

plotcircle(int x,int y, int x1, int y1)
{
putpixel(x+x1,y+y1,RED);
putpixel(x-x1,y+y1,RED);
putpixel(x+x1,y-y1,RED);
putpixel(x-x1,y-y1,RED);
putpixel(x+y1,y+x1,RED);
putpixel(x-y1,y+x1,RED);
putpixel(x+y1,y-x1,RED);
putpixel(x-y1,y-x1,RED);
return 0;
}

void cubic(int x1,int y1,int x2, int y2, int x3, int y3, int x4, int y4, int color)
{
int Cx[4],Cy[4];
int ax,ay,bx,by,cx,cy,dx,dy,x,y;
int i=0;
double stepsize,t;
Cx[0]=x1;
Cy[0]=y1;
Cx[1]=x2;
Cy[1]=y2;
Cx[2]=x3;
Cy[2]=y3;
Cx[3]=x4;
Cy[3]=y4;
for(i=0;i<4;i++)
   {
   setcolor(color);
   circl(Cx[i],Cy[i],3);
   }
setcolor(color);
ax=-Cx[0]+3*Cx[1]+(-3*Cx[2])+Cx[3];
ay=-Cy[0]+3*Cy[1]+(-3*Cy[2])+Cy[3];
bx=3*Cx[0]+(-6*Cx[1])+3*Cx[2];
by=3*Cy[0]+(-6*Cy[1])+3*Cy[2];
cx=-3*Cx[0]+3*Cx[1];
cy=-3*Cy[0]+3*Cy[1];
dx=Cx[0];
dy=Cy[0];
for(i=0;i<4;i++)
   {
   putpixel(Cx[i],Cy[i],RED);
   }
setcolor(WHITE);
for(i=0;i<3;i++)
   {
   line(Cx[i],Cy[i],Cx[(i+1)%4],Cy[(i+1)%4]);
   }
setcolor(RED);
stepsize=1.0/1000.0;
for(i=0;i<1000;i++)
{
t=stepsize*(double)i;
x=ax*(t*t*t)+bx*(t*t)+cx*t+dx;
y=ay*(t*t*t)+by*(t*t)+cy*t+dy;
putpixel(x,y,RED);
}
}

main()
{
int gd=DETECT,gm,x,y;
initgraph(&gd,&gm," ");

cleardevice();
cubic(50,300,100,50,250,50,350,300,6);
getch();
cleardevice();
cubic(50,300,350,300,100,50,250,50,6);
getch();
cleardevice();
cubic(50,300,100,50,350,300,250,50,6);
getch();
cleardevice();
cubic(350,300,50,300,100,50,250,50,6);
getch();

return 0;
}

 

Bezier Curves

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

void circl(int x, int y, int r)
{
int x1,y1,p;
x1=0;
y1=r;
p=3-2*r;

while(x1<y1)
    {
    plotcircle(x,y,x1,y1);
    if(p<0)
       p=p+4*x1+6;
    else
       {
       p=p+4*(x1-y1)+10;
       y1=y1-1;
       }
    x1=x1+1;
    }

if(x1==y1)
  plotcircle(x,y,x1,y1);
}

plotcircle(int x,int y, int x1, int y1)
{
putpixel(x+x1,y+y1,RED);
putpixel(x-x1,y+y1,RED);
putpixel(x+x1,y-y1,RED);
putpixel(x-x1,y-y1,RED);
putpixel(x+y1,y+x1,RED);
putpixel(x-y1,y+x1,RED);
putpixel(x+y1,y-x1,RED);
putpixel(x-y1,y-x1,RED);
return 0;
}

void cubic(int x1,int y1,int x2, int y2, int x3, int y3, int x4, int y4, int color)
{
int Cx[4],Cy[4];
int ax,ay,bx,by,cx,cy,dx,dy,x,y;
int i=0;
double stepsize,t;
Cx[0]=x1;
Cy[0]=y1;
Cx[1]=x2;
Cy[1]=y2;
Cx[2]=x3;
Cy[2]=y3;
Cx[3]=x4;
Cy[3]=y4;
for(i=0;i<4;i++)
   {
   setcolor(color);
   circl(Cx[i],Cy[i],3);
   }
setcolor(color);
ax=-Cx[0]+3*Cx[1]+(-3*Cx[2])+Cx[3];
ay=-Cy[0]+3*Cy[1]+(-3*Cy[2])+Cy[3];
bx=3*Cx[0]+(-6*Cx[1])+3*Cx[2];
by=3*Cy[0]+(-6*Cy[1])+3*Cy[2];
cx=-3*Cx[0]+3*Cx[1];
cy=-3*Cy[0]+3*Cy[1];
dx=Cx[0];
dy=Cy[0];
for(i=0;i<4;i++)
   {
   putpixel(Cx[i],Cy[i],RED);
   }
setcolor(WHITE);
for(i=0;i<3;i++)
   {
   line(Cx[i],Cy[i],Cx[(i+1)%4],Cy[(i+1)%4]);
   }
setcolor(RED);
stepsize=1.0/1000.0;
for(i=0;i<1000;i++)
{
t=stepsize*(double)i;
x=ax*(t*t*t)+bx*(t*t)+cx*t+dx;
y=ay*(t*t*t)+by*(t*t)+cy*t+dy;
putpixel(x,y,RED);
}
}

main()
{
int gd=DETECT,gm,x,y;
initgraph(&gd,&gm," ");

cleardevice();
cubic(50,300,100,50,250,50,350,300,6);
getch();
cleardevice();
cubic(50,300,350,300,100,50,250,50,6);
getch();
cleardevice();
cubic(50,300,100,50,350,300,250,50,6);
getch();
cleardevice();
cubic(350,300,50,300,100,50,250,50,6);
getch();

return 0;
}

 

Midpoint Ellipse Drawing Algorithm

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

#define ROUND(a) ((int)(a+0.5))

void plot_ellipse(int,int,int,int);

int xc,yc,rx,ry;

void main()
{
 int rx2,ry2,twoRx2,twoRy2;
 int i,j,x,y,p,px,py;

 int gd=DETECT,gm;
 initgraph(&gd,&gm,"");

 printf("Enter the co-ordinates of the centre:\n");
 scanf("%d%d",&xc,&yc);

 printf("Please enter the radius of the ellipse :\n");
 scanf("%d%d",&rx,&ry);
 cleardevice();

 rx2=rx*rx;
 ry2=ry*ry;
 twoRx2=2*rx2;
 twoRy2=2*ry2;
 x=0; y=ry;
 px=0; py=twoRx2*y;

 plot_ellipse(xc,yc,x,y);

 p=ROUND(ry2-(rx2*ry)+(0.25*rx2));
 while(px<py)
 {
 x++;
 px+=twoRy2;
 if(p<0)
  p+=ry2+px;
 else {
  y--;
  py-=twoRx2;
  p+=ry2+px-py;
 }
 plot_ellipse(xc,yc,x,y);
 }

 p=ROUND(ry2*(x+0.5)*(x+0.5)+rx2*(y-1)*(y-1)-rx2*ry2);
 while(y>0)
 {
 y--;
 py-=twoRx2;
 if(p>0)
  p+=rx2-py;
 else
       {
  x++;
  px+=twoRy2;
  p+=rx2-py+px;
       }
 plot_ellipse(xc,yc,x,y);
 }
 getch();
 }

 void plot_ellipse(int xc,int yc,int x,int y)
 {
 putpixel(xc+x,yc+y,4);
 putpixel(xc+x,yc-y,4);
 putpixel(xc-x,yc+y,4);
 putpixel(xc-x,yc-y,4);
 }

Midpoint Circle Drawing Algorithm

#include<stdio.h>
#include<graphics.h>
#include<math.h>

void midptcircle(int xcen,int ycen,int radius)
{
int x=0;
int y=radius;
int p=1-radius;
void plotpoints(int,int,int,int);
plotpoints(xcen,ycen,x,y);
while(x<y)
     {
     x++;
     if(p<0)
       p+=2*x+1;
     else
       {
       y--;
       p+=2*(x-y)+1;
       }
     plotpoints(xcen,ycen,x,y);
     }
}

void plotpoints(int xcen,int ycen,int x,int y)
{
putpixel(xcen+x,ycen+y,RED);
putpixel(xcen-x,ycen+y,RED);
putpixel(xcen+x,ycen-y,RED);
putpixel(xcen-x,ycen-y,RED);
putpixel(xcen+y,ycen+x,RED);
putpixel(xcen-y,ycen+x,RED);
putpixel(xcen+y,ycen-x,RED);
putpixel(xcen-y,ycen-x,RED);
}

int main()
{
int xcen,ycen,radius;
int gd=DETECT,gm;
clrscr();

printf("Enter centre of circle: ");
scanf("%d%d",&xcen,&ycen);
printf("\nEnter radius: ");
scanf("%d",&radius);
initgraph(&gd,&gm,"");
midptcircle(xcen,ycen,radius);
getch();
return 0;
}

DDA Line Drawing Algorithm

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

main()
   {
   int x1,y1,x2,y2;
   int gd=DETECT,gm;

   clrscr();
   printf("...........DDA Line Drawing Algorithm...........\n");
   printf("Enter starting co-ordinates : ");
   scanf("%d%d",&x1,&y1);
   printf("Enter ending co-ordinates : ");
   scanf("%d%d",&x2,&y2);
   initgraph(&gd,&gm,"");
   dda(x1,y1,x2,y2);
   getch();
   return 0;
   }


dda(int x1,int y1,int x2,int y2)
{
float dx,dy,step,k;
float xinc,yinc,x,y;

dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
   step=abs(dx);
else
   step=abs(dy);

xinc=dx/(float)step;
yinc=dy/(float)step;
x=x1;
y=y1;
putpixel(x,y,RED);
for(k=1;k<step;k++)
 {
 x+=xinc;
 y+=yinc;
 putpixel(x,y,RED);
 }
}


 

DDA Line Drawing Algorithm

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

main()
   {
   int x1,y1,x2,y2;
   int gd=DETECT,gm;

   clrscr();
   printf("...........DDA Line Drawing Algorithm...........\n");
   printf("Enter starting co-ordinates : ");
   scanf("%d%d",&x1,&y1);
   printf("Enter ending co-ordinates : ");
   scanf("%d%d",&x2,&y2);
   initgraph(&gd,&gm,"");
   dda(x1,y1,x2,y2);
   getch();
   return 0;
   }


dda(int x1,int y1,int x2,int y2)
{
float dx,dy,step,k;
float xinc,yinc,x,y;

dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
   step=abs(dx);
else
   step=abs(dy);

xinc=dx/(float)step;
yinc=dy/(float)step;
x=x1;
y=y1;
putpixel(x,y,RED);
for(k=1;k<step;k++)
 {
 x+=xinc;
 y+=yinc;
 putpixel(x,y,RED);
 }
}