Skip to main content

Posts

Showing posts with the label Bresenham circle

Bresenham's Circle Drawing Program (C++)

Bresenham's Circle Drawing C++ Program #include<conio.h> #include<Graphics.h> #include<stdio.h> void main() { int gd = DETECT, gm; initgraph (&gd, &gm, "C:\\TC\\BGI" ) ; int xc, yc, x, y, r, D; printf ( "Enter Radius of Circle: " ); scanf ( "%d" , &r); printf ( "Enter coordinates of centre of Circle: " ); scanf ( "%d%d" , &xc, &yc); x=0;      y=r; D=3-(2*r);             //Initial Decision parameter while (x<=y) { putpixel ( y+xc, x+yc, 15 );             //……octet-1 putpixel ( x+xc, y+yc, 15 );             //……octet-2 putpixel ( -x+xc, y+yc, 15 );           //……octet-3 putpixel ( -y+xc, x+yc, 15 );           //……octet-4 putp...

Bresenham's Circle Drawing Algorithm

Bresenham’s Circle Drawing Algorithm A circle is made up of 8 Equal Octets so we need to find only coordinates of any one octet rest we can conclude using that coordinates. We took octet-2. Where X and Y will represent the pixel Let us make a function Circle() with parameters coordinates of Centre (Xc,Yc) and pixel point (X,Y) that will plot the pixel on screen. We will find pixels assuming that Centre is at Origin (0,0) then we will add the coordinates of centre to corresponding X and Y while drawing circle on screen. Circle ( Xc,Yc,X,Y ) { Plot ( Y+Xc , X+Yc )           ……Octet-1 Plot ( X+Xc , Y+Yc )          ……Octet-2   Plot ( -X+Xc , Y+Yc )           ……Octet-3 Plot ( -Y+Xc , X+Yc )         …..Octet-4 Plot ( -Y+Xc , -X+Yc )        ……Octet-5 Plot ( -X+Xc , -Y+Y...