
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:
Baca Juga
- Program to implement DDA Line generation algorithm for all 4 quadrants of a plane (x and y axis should meet at centre(320,240) i.e., Origin O(0,0) of user coordinate system)-MASTER GUIDE
- Program to implement Cohen-Sutherland Line clipping algorithm. -MASTER GUIDE
- Program to transform object ( Tringle or rectangle or Polygon) from window to view port. - MASTER GUIDE
0 Response to "Program to draw a thick circle using moving pen method at a given centre-MASTER GUIDE"
Post a Comment