Skip to content

Commit

Permalink
Merge pull request pyqt#14 from iyadahmed/patch-1
Browse files Browse the repository at this point in the history
Fix and update mandelbrot example
  • Loading branch information
mherrmann authored Jul 26, 2021
2 parents 06f04f1 + 6910e68 commit 7069034
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pyqt-official/threads/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def rgbFromWaveLength(self, wave):
g = pow(g * s, 0.8)
b = pow(b * s, 0.8)

return qRgb(r*255, g*255, b*255)
return qRgb(int(r*255), int(g*255), int(b*255))


class MandelbrotWidget(QWidget):
Expand Down Expand Up @@ -251,7 +251,7 @@ def paintEvent(self, event):
painter.save()
painter.translate(newX, newY)
painter.scale(scaleFactor, scaleFactor)
exposed, _ = painter.matrix().inverted()
exposed, _ = painter.transform().inverted()
exposed = exposed.mapRect(self.rect()).adjusted(-1, -1, 1, 1)
painter.drawPixmap(exposed, self.pixmap, exposed)
painter.restore()
Expand All @@ -263,10 +263,10 @@ def paintEvent(self, event):

painter.setPen(Qt.NoPen)
painter.setBrush(QColor(0, 0, 0, 127))
painter.drawRect((self.width() - textWidth) / 2 - 5, 0, textWidth + 10,
painter.drawRect((self.width() - textWidth) // 2 - 5, 0, textWidth + 10,
metrics.lineSpacing() + 5)
painter.setPen(Qt.white)
painter.drawText((self.width() - textWidth) / 2,
painter.drawText((self.width() - textWidth) // 2,
metrics.leading() + metrics.ascent(), text)

def resizeEvent(self, event):
Expand Down

0 comments on commit 7069034

Please sign in to comment.