forked from hBuzzy/Task2_Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.cpp
More file actions
28 lines (26 loc) · 1.23 KB
/
Copy pathweb.cpp
File metadata and controls
28 lines (26 loc) · 1.23 KB
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
#include "web.h"
Web::Web() {}
void Web::drawWeb(QPainter *painter, const QPoint &StartPoint, bool drawCheck) {
if (drawCheck == true) {
int startPointX = StartPoint.x();
int startPointY = StartPoint.y();
const int kLineLength = 50;
const int kWebPointCount = 8;
const int kDivisorOfPi = 4;
QPoint pointsOfWeb[kWebPointCount];
double angel = 0;
for (int i {0}; i < kWebPointCount; i++) {
angel = angel + (M_PI / kDivisorOfPi);
pointsOfWeb[i].setX(startPointX + kLineLength * cos(angel));
pointsOfWeb[i].setY(startPointY + kLineLength * sin(angel));
}
painter->drawLine(startPointX, startPointY, pointsOfWeb[0].x(), pointsOfWeb[0].y());
painter->drawLine(pointsOfWeb[0].x(), pointsOfWeb[0].y(), pointsOfWeb[kWebPointCount - 1].x(), pointsOfWeb[kWebPointCount - 1].y());
for(int i {1}; i < kWebPointCount; i++){
painter->drawLine(startPointX, startPointY, pointsOfWeb[i].x(), pointsOfWeb[i].y());
painter->drawLine(pointsOfWeb[i - 1].x(), pointsOfWeb[i - 1].y(), pointsOfWeb[i].x(), pointsOfWeb[i].y());
}
} else {
return;
}
}