Draw cricle using Bresanham's circle drawing algorithm in C
#include"stdio.h"
#include"conio.h"
#include"graphics.h"
void bresan(int,int,int);
void pixel(int,int,float,float);
int main()
{
int gd=DETECT,gm;
int x,y,r;
clrscr();
initgraph(&gd,&gm,"");
printf("Enter the center point:");
scanf("%d%d",&x,&y);
printf("Enter the radius :");
scanf("%d",&r);
bresan(x,y,r);
getch();
return 0;
}
void bresan(int x,int y,int r)
{
int a,b;
float d;
a=0;b=r;
d=3-2*r;
while(a<=b)
{
a++;
if(d>=0)
{
b--;
d=d+10+4*(a-b);
}
else
d=d+(4*a)+6;
pixel(x,y,a,b);
}
}
void pixel(int x,int y,float a,float b)
{
putpixel(x+a,y+b,10);
putpixel(x-a,y-b,10);
putpixel(x+a,y-b,10);
putpixel(x-a,y+b,10);
putpixel(x+b,y+a,10);
putpixel(x-b,y-a,10);
putpixel(x+b,y-a,10);
putpixel(x-b,y+a,10);
}
#include"conio.h"
#include"graphics.h"
void bresan(int,int,int);
void pixel(int,int,float,float);
int main()
{
int gd=DETECT,gm;
int x,y,r;
clrscr();
initgraph(&gd,&gm,"");
printf("Enter the center point:");
scanf("%d%d",&x,&y);
printf("Enter the radius :");
scanf("%d",&r);
bresan(x,y,r);
getch();
return 0;
}
void bresan(int x,int y,int r)
{
int a,b;
float d;
a=0;b=r;
d=3-2*r;
while(a<=b)
{
a++;
if(d>=0)
{
b--;
d=d+10+4*(a-b);
}
else
d=d+(4*a)+6;
pixel(x,y,a,b);
}
}
void pixel(int x,int y,float a,float b)
{
putpixel(x+a,y+b,10);
putpixel(x-a,y-b,10);
putpixel(x+a,y-b,10);
putpixel(x-a,y+b,10);
putpixel(x+b,y+a,10);
putpixel(x-b,y-a,10);
putpixel(x+b,y-a,10);
putpixel(x-b,y+a,10);
}
How to register online and bet on casino games in NJ?
ReplyDeleteNJ online 전주 출장샵 casino and sports betting is 군포 출장안마 in full swing, as this 창원 출장샵 NJ online sports betting site launched with 삼척 출장샵 a lot of 김천 출장마사지 buzz. Here you can