/*PRACTICAL NO. 2
*/
TITLE : Write C++/Java program to draw circle using Bresenham‘s algorithm. Inherit pixel class.#include<iostream>
#include<graphics.h>
using namespace std; class Pixel
{
public:
void pixel(int X,int Y,int x,int y)
{
putpixel(X+x, Y+y, RED);
putpixel(X-x, Y+y, RED);
putpixel(X+x, Y-y, RED);
putpixel(X-x, Y-y, RED);
putpixel(X+y, Y+x, RED);
putpixel(X-y, Y+x, RED);
putpixel(X+y, Y-x, RED);
putpixel(X-y, Y-x, RED); }
}; class Bresenham : public Pixel
{
public:
void Bres_algo(int X,int Y,int r)
{
int x=0;
int y=r;
int d = 3-(2*r);
pixel(X,Y,x,y);
do
{
if(d<0)
{
d = d+(4*x)+6;
}
else
{
d = d+4*(x-y)+10;
y--;
}
x++;
pixel(X,Y,x,y);
}while(x<=y);
}
}; int main()
{
int X,Y,r;
Bresenham b;
cout<<"\nBRESENHAM CIRCLE DRAWING.....";
cout<<"\n Enter the co-ordinates (X,Y) :";
cin>>X>>Y;
cout<<"\n Enter the Radius :";
cin>>r;
int gd = DETECT, gm;
initgraph(&gd,&gm,NULL);
b.Bres_algo(X,Y,r);
getch();
delay(100000);
closegraph();
return 0;
}//bresenham s algorithm draw circle using bresenham s algorithm java program to draw circle
blog about computer science ,here we provide detailed information about topics in computer science.Computer graphics programming,computer graphics concepts,microprocessor assembly language programming. computer networking,computer programming,artificial intelligence,computer hardware,etc here you will find detailed explanation of topics
Search This Blog
PRACTICAL NO. 2 TITLE : Write C++/Java program to draw circle using Bresenham‘s algorithm. Inherit pixel class.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment