-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboardlayer.cpp
More file actions
42 lines (36 loc) · 1.12 KB
/
boardlayer.cpp
File metadata and controls
42 lines (36 loc) · 1.12 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
#include "boardlayer.h"
#include <QSvgRenderer>
#include <QPainter>
#include <QPixmap>
BoardLayer::BoardLayer() {
_loaded = false;
}
bool BoardLayer::loadSvg(QString filename, QColor backgroundColor) {
if( _loaded ) {
delete pixmapItem;
}
QSvgRenderer renderer;
renderer.load(filename);
// QPixmap image("c:/temp/test.png");
QPixmap image(renderer.defaultSize()*3);
image.fill(backgroundColor);
QPainter painter(&image);
renderer.render(&painter);
painter.setCompositionMode( QPainter::CompositionMode_SourceIn );
painter.fillRect(image.rect(), QColor(0,255,0));
painter.end();
pixmapItem = new QGraphicsPixmapItem(image);
_loaded = true;
return true;
}
void BoardLayer::setColor(QColor color) {
QPixmap image = pixmapItem->pixmap();
QPainter painter(&image);
painter.setCompositionMode( QPainter::CompositionMode_SourceIn );
painter.fillRect(image.rect(), color);
painter.end();
pixmapItem->setPixmap(image);
}
void BoardLayer::setAbsoluteRotation( float angle ) {
pixmapItem->setRotation(angle);
}