-
Notifications
You must be signed in to change notification settings - Fork 1
/
CircleDashAndDot.cpp
70 lines (64 loc) · 1.75 KB
/
CircleDashAndDot.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<iostream>
#include<conio.h>
#include<graphics.h>
#include<math.h>
using namespace std;
void circler(int radius,int xc,int yc);
int main12()
{
int gDriver=DETECT,gMode;
initgraph(&gDriver,&gMode,"c:\\tc\\bgi");
int radius,xc,yc;
cout<<endl<<"enter centre point:";
cout<<endl<<"XC:";
cin>>xc;
cout<<endl<<"YC:";
cin>>yc;
cout<<endl<<"radius:";
cin>>radius;
cleardevice();
circler(radius,xc,yc);
getch();
return 0;
}
void circler(int radius,int xc,int yc)
{
int p,x,y;
void drawl(int x,int y,int xc,int yc);
p=1-radius;
x=0;
int cnt=0;
y=radius;
drawl(x,y,xc,yc);
while(x<=y)
{
x++;
if(p<0)
{
p+=2*x+1;
}
else
{
p+=2*(x-y)+1;
y--;
}
drawl(x,y,xc,yc);
if(cnt==1||cnt==0)
x+=2;
if(cnt==9)
cnt=0;
else
cnt++;
}
}
void drawl(int x,int y,int xc,int yc)
{
putpixel(xc+x,yc+y,12);
putpixel(xc+x,yc-y,12);
putpixel(xc-x,yc+y,12);
putpixel(xc-x,yc-y,12);
putpixel(xc+y,yc+x,12);
putpixel(xc-y,yc+x,12);
putpixel(xc+y,yc-x,12);
putpixel(xc-y,yc-x,12);
}