added x/y offset of text in preview
This commit is contained in:
parent
153ba91231
commit
f639760ffc
11
core.py
11
core.py
|
@ -26,7 +26,7 @@ class Core():
|
|||
except:
|
||||
return "avconv"
|
||||
|
||||
def drawBaseImage(self, backgroundImage, titleText, titleFont, alignment):
|
||||
def drawBaseImage(self, backgroundImage, titleText, titleFont, alignment, xOffset, yOffset):
|
||||
|
||||
if self._image == None or not self.lastBackgroundImage == backgroundImage:
|
||||
self.lastBackgroundImage = backgroundImage
|
||||
|
@ -49,13 +49,16 @@ class Core():
|
|||
painter.setFont(font)
|
||||
painter.setPen(QColor(255, 255, 255))
|
||||
|
||||
yPosition = 375 + yOffset
|
||||
|
||||
fm = QtGui.QFontMetrics(font)
|
||||
if alignment == "Left":
|
||||
painter.drawText(70, 375, titleText)
|
||||
xPosition = 70 + xOffset
|
||||
if alignment == "Middle":
|
||||
painter.drawText(1280/2 - fm.width(titleText)/2, 375, titleText)
|
||||
xPosition = xOffset + (1280/2 - fm.width(titleText)/2)
|
||||
if alignment == "Right":
|
||||
painter.drawText(1210 - fm.width(titleText), 375, titleText)
|
||||
xPosition = xOffset + (1210 - fm.width(titleText))
|
||||
painter.drawText(xPosition, yPosition, titleText)
|
||||
painter.end()
|
||||
|
||||
buffer = QtCore.QBuffer()
|
||||
|
|
8
main.py
8
main.py
|
@ -14,7 +14,7 @@ import preview_thread, core, video_thread
|
|||
|
||||
class Main(QtCore.QObject):
|
||||
|
||||
newTask = QtCore.pyqtSignal(str, str, QFont, str)
|
||||
newTask = QtCore.pyqtSignal(str, str, QFont, str, int, int)
|
||||
processTask = QtCore.pyqtSignal()
|
||||
videoTask = QtCore.pyqtSignal(str, str, QFont, str, str, str)
|
||||
|
||||
|
@ -50,6 +50,8 @@ class Main(QtCore.QObject):
|
|||
window.fontComboBox.currentFontChanged.connect(self.drawPreview)
|
||||
window.lineEdit_title.textChanged.connect(self.drawPreview)
|
||||
window.alignmentComboBox.currentIndexChanged.connect(self.drawPreview)
|
||||
window.textXSpinBox.valueChanged.connect(self.drawPreview)
|
||||
window.textYSpinBox.valueChanged.connect(self.drawPreview)
|
||||
|
||||
window.progressBar_create.setValue(0)
|
||||
window.setWindowTitle("Audio Visualizer")
|
||||
|
@ -145,7 +147,9 @@ class Main(QtCore.QObject):
|
|||
self.newTask.emit(self.window.label_background.text(),
|
||||
self.window.lineEdit_title.text(),
|
||||
self.window.fontComboBox.currentFont(),
|
||||
self.window.alignmentComboBox.currentText())
|
||||
self.window.alignmentComboBox.currentText(),
|
||||
self.window.textXSpinBox.value(),
|
||||
self.window.textYSpinBox.value())
|
||||
# self.processTask.emit()
|
||||
|
||||
def showPreviewImage(self, image):
|
||||
|
|
|
@ -19,14 +19,16 @@ class Worker(QtCore.QObject):
|
|||
self.queue = queue
|
||||
|
||||
|
||||
@pyqtSlot(str, str, QtGui.QFont, str)
|
||||
def createPreviewImage(self, backgroundImage, titleText, titleFont, alignment):
|
||||
@pyqtSlot(str, str, QtGui.QFont, str, int, int)
|
||||
def createPreviewImage(self, backgroundImage, titleText, titleFont, alignment, xOffset, yOffset):
|
||||
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
||||
dic = {
|
||||
"backgroundImage": backgroundImage,
|
||||
"titleText": titleText,
|
||||
"titleFont": titleFont,
|
||||
"alignment": alignment
|
||||
"alignment": alignment,
|
||||
"xoffset": xOffset,
|
||||
"yoffset": yOffset
|
||||
}
|
||||
self.queue.put(dic)
|
||||
|
||||
|
@ -44,7 +46,9 @@ class Worker(QtCore.QObject):
|
|||
nextPreviewInformation["backgroundImage"],
|
||||
nextPreviewInformation["titleText"],
|
||||
nextPreviewInformation["titleFont"],
|
||||
nextPreviewInformation["alignment"])
|
||||
nextPreviewInformation["alignment"],
|
||||
nextPreviewInformation["xoffset"],
|
||||
nextPreviewInformation["yoffset"])
|
||||
|
||||
spectrum = numpy.fromfunction(lambda x: 0.008*(x-128)**2, (255,), dtype="int16")
|
||||
|
||||
|
|
Reference in New Issue