From 41d557743a11a42c7d393bee169aff08cf0254d4 Mon Sep 17 00:00:00 2001 From: Gitea Date: Fri, 30 Aug 2019 12:38:15 +0200 Subject: [PATCH] Replaces blend pixmap with fillRect --- osciwidget.cpp | 15 +++++---------- osciwidget.h | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/osciwidget.cpp b/osciwidget.cpp index c7ffd10..94e2ea5 100644 --- a/osciwidget.cpp +++ b/osciwidget.cpp @@ -22,7 +22,6 @@ OsciWidget::OsciWidget(QWidget *parent) : { restartTimer(); resizePixmap(); - createBlendPixmap(); } int OsciWidget::framerate() const @@ -60,7 +59,6 @@ void OsciWidget::setBlend(int blend) qDebug() << "change blend to" << blend; m_blend = blend; - createBlendPixmap(); } void OsciWidget::setFactor(float factor) @@ -109,10 +107,11 @@ void OsciWidget::paintEvent(QPaintEvent *event) painter.begin(this); painter.drawPixmap(0, 0, m_pixmap); painter.end(); + // Fade pixmap by multiplying all pixels by m_blend painter.begin(&m_pixmap); painter.setCompositionMode(QPainter::CompositionMode_Multiply); - painter.drawPixmap(0, 0, m_fadeoutPixmap); + painter.fillRect(m_pixmap.rect(), QColor(m_blend,m_blend,m_blend)); painter.end(); } @@ -131,7 +130,6 @@ void OsciWidget::resizeEvent(QResizeEvent *event) Q_UNUSED(event) resizePixmap(); - createBlendPixmap(); } void OsciWidget::restartTimer() @@ -142,14 +140,11 @@ void OsciWidget::restartTimer() m_timerId = startTimer(1000/m_framerate); } +{ +} + void OsciWidget::resizePixmap() { m_pixmap = QPixmap(size()); m_pixmap.fill(QColor()); } - -void OsciWidget::createBlendPixmap() -{ - m_fadeoutPixmap = QPixmap(size()); - m_fadeoutPixmap.fill(QColor(m_blend, m_blend, m_blend)); -} diff --git a/osciwidget.h b/osciwidget.h index 64d2ab0..2d54d26 100644 --- a/osciwidget.h +++ b/osciwidget.h @@ -46,7 +46,6 @@ private: float m_factor{4.f}; QPixmap m_pixmap; - QPixmap m_fadeoutPixmap; std::optional m_lastPoint; };