-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpainter.cpp
More file actions
30 lines (27 loc) · 829 Bytes
/
painter.cpp
File metadata and controls
30 lines (27 loc) · 829 Bytes
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
#include "painter.h"
Painter::Painter(PaintArea* parent) : m_parent(parent), m_points(parent->points()), m_mutex(parent->vectorMutex())
{
}
void Painter::run()
{
while (true) {
//if (m_mutex->tryLock()) {
if (m_points->empty()) {
continue;
}
auto image = m_parent->overlayImage();
auto color = m_parent->brushColor();
auto point = m_points->front();
auto radius = m_parent->brushRadius();
for (int y = -radius; y <= radius; y++) {
for (int x = -radius; x <= radius; x++) {
if (x * x + y * y <= radius * radius) {
image.setPixel(point.x() + x, point.y() + y, color.rgb());
}
}
}
m_points->pop_front();
// m_mutex->unlock();
//}
}
}