# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1568136253 14400 # Node ID c93a436e6decf55940e12418113ba5c9a352a2c6 # Parent 9922cde5ad6c8e61ec04b8cea782d744899c9362 color: new palette_to_pixmap function I plan to draw these little pixmaps in a drop-down button so people can choose from a few standard palettes. diff --git a/colors.py b/colors.py --- a/colors.py +++ b/colors.py @@ -96,3 +96,15 @@ ] +def palette_to_pixmap(palette): + pixmap = QG.QPixmap(QC.QSize(80, 20)) + painter = QG.QPainter(pixmap) + palette = [QG.QColor(NES_PALETTE[colour_idx]) for colour_idx in palette] + for idx, colour in enumerate(palette): + painter.setPen(colour) + brush = QG.QBrush() + brush.setColor(colour) + brush.setStyle(QC.Qt.SolidPattern) + painter.setBrush(brush) + painter.drawRect(idx*20, 0, idx*20 + 19, 19) + return pixmap