-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.cpp
117 lines (106 loc) · 1.71 KB
/
Point.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
#include "Point.h"
Point::Point()
{
lineWidth = 1.0;
COLOR c = {0.0f, 0.0f, 0.0f};
lineColor = c;
}
Point::Point(float x, float y)
{
pos.X = x;
pos.Y = y;
lineWidth = 1.0;
COLOR c = {0.0f, 0.0f, 0.0f};
lineColor = c;
}
Point::Point(COORD p)
{
pos = p;
lineWidth = 1.0;
COLOR c = {0.0f, 0.0f, 0.0f};
lineColor = c;
}
Point::~Point()
{
}
COORD Point::getPos() const
{
return pos;
}
void Point::setPos(COORD p)
{
pos = p;
}
float Point::getLineWidth() const
{
return lineWidth;
}
void Point::setLineWidth(float p)
{
lineWidth = p;
//Disappear();
//Draw();
}
COLOR Point::getLineColor() const
{
return lineColor;
}
void Point::setLineColor(float r, float g, float b)
{
COLOR pc = {r,g,b};
lineColor = pc;
//Disappear();
//Draw();
}
void Point::Draw()
{
glPointSize(lineWidth);
glColor3f(lineColor.R, lineColor.G, lineColor.B);
glBegin(GL_POINT); //glBegin和glEnd标明绘制图形的属性
glVertex2d(pos.X, pos.Y); //2i表示位置为两个int型变量
glEnd();
glFlush(); //flush缓冲区立即执行
}
void Point::Up()
{
pos.Y += 40;
}
void Point::Down()
{
pos.Y -= 40;
}
void Point::Left()
{
pos.X -= 40;
}
void Point::Right()
{
pos.X += 40;
}
void Point::Increase()
{
}
void Point::Decrease()
{
}
void Point::Rotate(char ch)
{
}
void Point::Fill(float r, float g, float b)
{
}
void Point::Disappear()
{
Point p(pos.X, pos.Y);
p.setLineColor(1,1,1);
p.setLineWidth(lineWidth);
p.Draw();
}
string Point::SaveFile()
{
string space = " ";
string p = float2str(pos.X) + space + float2str(pos.Y) + space;
string s = "point " + p + float2str(lineWidth) + space + COLOR2str(lineColor);
cout<<s<<endl;
return s;
}