Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
it compiles!
[graphlib.git] / DrawingArea.cpp
1 #include <DrawingArea.h>
2
3 DrawingArea::DrawingArea(int width, int height)
4 {
5     image = new QImage(width, height, QImage::Format_RGB32);
6     image->fill(QColor(Qt::white).rgb());
7     painter = new QPainter(image);
8 }
9
10 DrawingArea::~DrawingArea()
11 {
12     delete painter;
13     delete image;
14 }
15
16 int DrawingArea::width() const
17 {
18     return image->width();
19 }
20
21 int DrawingArea::height() const
22 {
23     return image->height();
24 }
25
26 void DrawingArea::setColor(const QColor &color)
27 {
28     QPen pen(painter->pen());
29     pen.setColor(color);
30     painter->setPen(pen);
31 }
32
33 void DrawingArea::setColor(float red, float green, float blue)
34 {
35     QColor color;
36     color.setRgbF(red, green, blue);
37     this->setColor(color);
38 }
39
40 void DrawingArea::drawPoint(int x, int y)
41 {
42     painter->drawPoint(x, y);
43 }
44
45 void DrawingArea::drawLine(int x1, int y1, int x2, int y2)
46 {
47     painter->drawLine(x1, y1, x2, y2);
48 }
49