Exemplo n.º 1
0
    def __init__(self):
        QMainWindow.__init__(self)

        width = int(sys.argv[2])
        height = int(sys.argv[3])
        self.setMinimumSize(QSize(width, height))
        self.setWindowTitle("MandelbrotQtViewer")

        pixmap = QPixmap(width, height).toImage()
        pixmap.fill(PyQt5.QtGui.QColor.fromRgb(255, 255, 255))

        maxSteps = int(sys.argv[1])
        print(maxSteps)
        for row in range(height):
            for col in range(width):
                steps = mandleInit(col, row, width, height, maxSteps)
                colorValue = 255 * (1 - (steps / maxSteps))
                inverted = 255 - colorValue

                red = 0
                green = 0
                blue = 0

                if steps != maxSteps:
                    red = inverted
                    green = inverted
                    blue = colorValue

                pixmap.setPixelColor(
                    col, row, PyQt5.QtGui.QColor.fromRgb(red, green, blue))

        palette = QPalette()
        palette.setBrush(PyQt5.QtGui.QPalette.Background,
                         PyQt5.QtGui.QBrush(pixmap))
        self.setPalette(palette)
Exemplo n.º 2
0
    def update_label(self):
        text, color = config.get_current_label()

        image = QPixmap(15, 15).toImage()
        qt_color = QColor(to_hex(color))
        for x in range(image.width()):
            for y in range(image.height()):
                image.setPixelColor(x, y, qt_color)

        self.label_button.setText("  " + text)
        self.label_button.setIcon(QIcon(QPixmap.fromImage(image)))