-
Notifications
You must be signed in to change notification settings - Fork 1
/
midpoint-circle-drawing.cpp
48 lines (44 loc) · 1.01 KB
/
midpoint-circle-drawing.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
#include<iostream>
#include<graphics.h>
#include<conio.h>
using namespace std;
int main()
{
int gd = DETECT, gm = CGAC0;
initgraph(&gd, &gm, "C:\\TC\\BGI");
int r, xc, yc;
float x, y, P;
cout<<"Enter radius and center(x,y): ";
cin>>r>>xc>>yc;
for(int i=5; i>0; i--, r--) {
x = 0;
y = r;
P = (5/4) - r;
while(x<y){
if(P<0)
{
P += 2*x + 3;
x += 1;
y = y;
}
else
{
P += 2*x - 2*y + 5;
x += 1;
y -= 1;
}
putpixel(x + xc, y + yc, rand()%14);
putpixel(y + xc, x + yc, rand()%14);
putpixel(x + xc, -y + yc, rand()%14);
putpixel(-y + xc, x + yc, rand()%14);
putpixel(-x + xc, -y + yc, rand()%14);
putpixel(-y + xc, -x + yc, rand()%14);
putpixel(-x + xc, y + yc, rand()%14);
putpixel(y + xc, -x + yc, rand()%14);
//delay(5);
};
}
getch();
closegraph();
return 0;
}