-->
Program to draw a thick circle using moving pen method at a given centre-MASTER GUIDE

Program to draw a thick circle using moving pen method at a given centre-MASTER GUIDE

Program to draw a thick circle using moving pen method at a given centre 

#include<graphics.h>

void pen(int x,int y,int c) ;

void circlepts(int xc,int yc,int x,int y,int clr);

void main()

{

int gd=DETECT,gm;

int x,y,xc,yc,r,p;

initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");

cleardevice();

printf("Enter the center of circle:");

scanf("%d%d" ,&xc,&yc);

printf("Enter Radius of circle:");

scanf("%d",&r);

x=0;

y=r;

p=1-r;

while(x<=y)

{

circlepts(xc,yc,x,y,RED);

x++;

if(p<0)

p=p+2*x+3;

else

{

y--;

p=p+2*(x-y)+5;

}

delay(50);

}

getch();

closegraph();

}


void circlepts(int xc,int yc,int x,int y,int clr)

{

pen(xc+x,yc+y,clr);

pen(xc-x,yc+y,clr);

pen(xc+x,yc-y,clr);

pen(xc-x,yc-y,clr);

pen(xc+y,yc+x,clr);

pen(xc-y,yc+x,clr);

pen(xc+y,yc-x,clr);

pen(xc-y,yc-x,clr);

}


void pen(int x,int y,int c)

{

putpixel(x,y,c);

putpixel(x,y+1,c);

putpixel(x,y-1,c);

putpixel(x+1,y,c);

putpixel(x+1,y+1,c);

putpixel(x+1,y-1,c);

putpixel(x-1,y,c);

putpixel(x-1,y+1,c);

putpixel(x-1,y-1,c);

}


OUTPUT:



Related Posts

0 Response to "Program to draw a thick circle using moving pen method at a given centre-MASTER GUIDE"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel