aboutsummaryrefslogtreecommitdiff
path: root/core.py
diff options
context:
space:
mode:
authorMartin Kaistra2017-04-22 10:42:31 +0200
committerMartin Kaistra2017-04-22 10:42:31 +0200
commit6eb601ca9ab2d9efbe591e5f6ae0f19e732260a6 (patch)
tree9677c2cf51695134e6ffbfc288e33fb74a7ba667 /core.py
parent19cf45785461ffd44c8bdec7ae4634bf828e75ed (diff)
parent4aef5bfdb7f04dde13b1c6a94172824ce143be6e (diff)
Merge branch 'font-settings#8' of https://github.com/HunterwolfAT/audio-visualizer-python into HunterwolfAT-font-settings#8
Diffstat (limited to 'core.py')
-rw-r--r--core.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/core.py b/core.py
index 895d1a9..b362087 100644
--- a/core.py
+++ b/core.py
@@ -26,7 +26,7 @@ class Core():
except:
return "avconv"
- def drawBaseImage(self, backgroundImage, titleText, titleFont):
+ def drawBaseImage(self, backgroundImage, titleText, titleFont, fontSize, alignment, xOffset, yOffset):
if self._image == None or not self.lastBackgroundImage == backgroundImage:
self.lastBackgroundImage = backgroundImage
@@ -45,11 +45,20 @@ class Core():
self._image1 = QtGui.QImage(self._image)
painter = QPainter(self._image1)
font = titleFont
- font.setPointSizeF(35)
+ font.setPointSizeF(fontSize)
painter.setFont(font)
painter.setPen(QColor(255, 255, 255))
- painter.drawText(70, 375, titleText)
+ yPosition = yOffset
+
+ fm = QtGui.QFontMetrics(font)
+ if alignment == 0: #Left
+ xPosition = xOffset
+ if alignment == 1: #Middle
+ xPosition = xOffset - fm.width(titleText)/2
+ if alignment == 2: #Right
+ xPosition = xOffset - fm.width(titleText)
+ painter.drawText(xPosition, yPosition, titleText)
painter.end()
buffer = QtCore.QBuffer()