-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircle.h
46 lines (33 loc) · 1.05 KB
/
Circle.h
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
#ifndef CIRCLE_H_INCLUDED
#define CIRCLE_H_INCLUDED
#include<bits/stdc++.h>
#include "Main.h"
using namespace std;
bool isInsideCircle(int circle_x, int circle_y,int rad, int x, int y)
{
if ((x - circle_x) * (x - circle_x) + (y - circle_y) * (y - circle_y) <= rad * rad)
return true;
else
return false;
}
void Bressenham(int r,int centerX,int centerY,int color)
{
int d = 3-2*r;
int tot = round(double(r)/sqrt(2.0));
int y = round(sqrt(double(r*r-0)));
for(int i=0;i<=tot;i++)
{
drawPixel(PT(i+centerX,y+centerY),color,3);
drawPixel(PT(i+centerX,-y+centerY),color,3);
drawPixel(PT(-i+centerX,y+centerY),color,3);
drawPixel(PT(-i+centerX,-y+centerY),color,3);
drawPixel(PT(y+centerX,i+centerY),color,3);
drawPixel(PT(-y+centerX,i+centerY),color,3);
drawPixel(PT(y+centerX,-i+centerY),color,3);
drawPixel(PT(-y+centerX,-i+centerY),color,3);
if(d<0) d += 4*i+6;
else d+= 4*i-4*y+10;
if(d>0) y -= 1;
}
}
#endif // CIRCLE_H_INCLUDED