
Bresenham's method of drawing the circle avoids trigonometric and square root calculations by using only integer operations involving squares of the pixel separation distances.
It considers the eight way symmetry of the circle and plots 1/8th part of circle from 90(D) to 45(D). As circle is drawn from 90 to 45 degree , the x moves in +ve direction and y moves in -ve direction.
Bresenham's Circle drawing Program in C
#include<stdio.h> #include<conio.h> #include<graphics.h> void bresenhamcircle(int cx,int cy,int x,int y) { putpixel(cx+x,cy+y,RED); putpixel(cx-x,cy+y,RED); putpixel(cx+x,cy-y,RED); putpixel(cx-x,cy-y,RED); putpixel(cx+y,cy+x,RED); putpixel(cx-y,cy+x,RED); putpixel(cx+y,cy-x,RED); putpixel(cx-y,cy-x,RED); } void main() { int cx,cy,x = 0,y,r,p; int gd=DETECT,gm; clrscr(); printf("Enter the coordinates for centre of the circle: "); scanf("%d %d",&cx,&cy); printf("Enter radius of : "); scanf("%d",&r); y=r; p=3-2*r; initgraph(&gd,&gm,""); cleardevice(); while(x<y) { bresenhamcircle(cx,cy,x,y); x++; if(p<0) p=p+4*x+6; else { y--; p=p+4*(x-y)+10; } bresenhamcircle(cx,cy,x,y); delay(200); } getch(); }
Bresenham's Circle Drawing Alogrithm