-
Notifications
You must be signed in to change notification settings - Fork 0
/
Circle.cpp
126 lines (111 loc) · 2.02 KB
/
Circle.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "Circle.h"
Circle::Circle()
{
COORD c = {0.0, 0.0};
center = c;
radiusa = 0.0;
radiusb = 0.0;
lineWidth = 1.0f;
COLOR lc = {0.0f, 0.0f, 0.0f};
lineColor = lc;
}
Circle::Circle(COORD c, float r)
{
center = c;
radiusa = r;
radiusb = r;
lineWidth = 1.0f;
COLOR lc = {0.0f, 0.0f, 0.0f};
lineColor = lc;
}
Circle::~Circle()
{
}
void Circle::setLineColor(float r, float g, float b)
{
COLOR c = {r,g,b};
lineColor = c;
//Disappear();
//Draw();
}
COLOR Circle::getLineColor() const
{
return lineColor;
}
void Circle::setLineWidth(float lw)
{
lineWidth = lw;
//Disappear();
//Draw();
}
float Circle::getLineWidth() const
{
return lineWidth;
}
void Circle::Draw()
{
Elipse circle(center, radiusa, radiusb);
circle.setLineWidth(lineWidth);
circle.setLineColor(lineColor.R, lineColor.G, lineColor.B);
circle.Draw();
if(filled == true)
Fill(fillColor.R, fillColor.G, fillColor.B);
}
void Circle::Up()
{
center.Y += 40;
}
void Circle::Down()
{
center.Y -= 40;
}
void Circle::Left()
{
center.X -= 40;
}
void Circle::Right()
{
center.X += 40;
}
void Circle::Increase()
{
radiusa += 20;
radiusb += 20;
}
void Circle::Decrease()
{
radiusa -= 20;
radiusb -= 20;
}
void Circle::Rotate(char ch)
{
}
void Circle::Fill(float r, float g, float b)
{
filled = true;
COLOR fc = {r, g, b};
fillColor = fc;
for(int i= 0; i < radiusa-3; i=i+5)
{
Circle c(center, i);
c.setLineColor(r,g,b);
c.setLineWidth(5);
c.Draw();
}
}
void Circle::Disappear()
{
Elipse cc(center, radiusa, radiusb);
cc.setLineWidth(lineWidth);
cc.setLineColor(1,1,1);
cc.Draw();
}
string Circle::SaveFile()
{
string space = " ";
string p = float2str(center.X) + space + float2str(center.Y) + space +float2str(radiusa) + space ;
string fill = bool2str(filled) + space + COLOR2str(fillColor) + space;
string s = "circle " + p + float2str(lineWidth) + space + COLOR2str(lineColor) +space + fill;
cout<<s<<endl;
return s;
}