-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMPCIRC.CPP
48 lines (48 loc) · 933 Bytes
/
MPCIRC.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//Midpoint Circle Drawing Algorithm
#include<stdio.h>
#include<iostream.h>
#include<graphics.h>
#include<conio.h>
void display(int xc,int yc,int X,int Y)
{
putpixel(xc+X,yc+Y,RED);
putpixel(xc-X,yc+Y,RED);
putpixel(xc+X,yc-Y,RED);
putpixel(xc-X,yc-Y,RED);
putpixel(xc+Y,yc+X,RED);
putpixel(xc-Y,yc+X,RED);
putpixel(xc+Y,yc-X,RED);
putpixel(xc-Y,yc-X,RED);
}
//Function to draw circle using MidPoint Algo
void midpoint(int xc,int yc,int r)
{
int X=0;
int Y=r;
int deci=1-r;
display(xc,yc,X,Y);
while(X<=Y)
{
if(deci>0)
{
Y--;
X++;
deci=deci+2*(X-Y)+1;
}
else
{
X++;
deci=deci+(2*X)+1;
}
display(xc,yc,X,Y);
}
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:/TURBOC3/BGI");
cout<<" <GRAPHICS MODE> "<<endl;
midpoint(200,200,50);
getch();
closegraph();
}