-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpainter.cpp
More file actions
54 lines (43 loc) · 1.22 KB
/
painter.cpp
File metadata and controls
54 lines (43 loc) · 1.22 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
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
#include "painter.h"
Painter::Painter()
{
}
Painter::Painter(Canvas &canvas)
{
set_canvas(canvas);
pen = QPen(Qt::black, 1);
painter.setPen(pen);
}
void Painter::set_canvas(Canvas &canvas)
{
this->canvas = &canvas;
painter.begin(&canvas.get_pixmap());
size_int temp_s = canvas.get_size();
painter.eraseRect(0, 0, temp_s.width, temp_s.height);
//todo функция для очистки канваса. Хранить массив
//не фоновых пикселей и зкарашивать их поточечно для очистки
}
error Painter::set_pixel(Canvas_point point, QColor color)
{
error rc = NO;
size_int size = canvas->get_size();
Screen_point point_for_draw(point, size);
if (point_for_draw.get_point().x < size.width &&
point_for_draw.get_point().y < size.height &&
point_for_draw.get_point().x >= 0 &&
point_for_draw.get_point().y >= 0)
{
pen.setColor(color);
painter.setPen(pen);
painter.drawPoint(point_for_draw.get_x(), point_for_draw.get_y());
}
else
{
rc = COORDS_OUTSIDE_CANVAS;
}
return rc;
}
const Canvas &Painter::get_canvas()
{
return *(this->canvas);
}