-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolygon.cpp
49 lines (38 loc) · 905 Bytes
/
polygon.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 "polygon.h"
Polygon::Polygon(QPen& pen, QBrush& brush)
{
this->_poly = QPolygon();
this->_pen = pen;
this->_brush = brush;
this->_rotation = 0;
}
Polygon::Polygon(Qt::PenStyle penColor, Qt::BrushStyle brushColor)
{
this->_poly = QPolygon();
this->_pen = QPen(penColor);
this->_brush = QBrush(brushColor);
this->_rotation = 0;
}
Polygon::~Polygon()
{
}
void Polygon::addPoint(QPoint point)
{
this->_poly << point;
}
void Polygon::draw(QPainter *painter)
{
QPen oldPen = painter->pen();
QBrush oldBrush = painter->brush();
painter->setPen(this->_pen);
painter->setBrush(this->_brush);
painter->rotate(this->_rotation);
painter->drawPolygon(this->_poly);
painter->rotate(-this->_rotation);
painter->setBrush(oldBrush);
painter->setPen(oldPen);
}
void Polygon::rotate(int degrees)
{
this->_rotation += degrees;
}