def __init__(self, parent): super(HueSliderWidget, self).__init__(parent) self.setFixedSize(parent.width(), parent.height()) self.value = 0 size = 100 self.colorImage = QtGui.QImage(1, size, QtGui.QImage.Format_RGB32) c = QColor() for y in range(0, size): k = y / float(size) c.setHsvF(k, 1.0, 1.0) self.colorImage.setPixel(0, y, c.rgb()) self.setCursor(Qt.PointingHandCursor)
def __init__(self, parent): super(AlphaSliderWidget, self).__init__(parent) self.setFixedSize(parent.width(), parent.height()) self.setCursor(Qt.PointingHandCursor) self.value = 0 size = 100 self.colorImage = QtGui.QImage(size, 1, QtGui.QImage.Format_RGB32) c = QColor() for x in range(0, size): k = x / float(size) c.setHsvF(1.0, 0.0, k) self.colorImage.setPixel(x, 0, c.rgb())
def generateHSVImage(w, h, hue, img=None): if not img: img = QtGui.QImage(w, h, QtGui.QImage.Format_RGB32) du = 1.0 / w dv = 1.0 / h c = QColor() for y in range(0, h): for x in range(0, w): s = du * x v = 1.0 - dv * y c.setHsvF(hue, s, v) img.setPixel(x, y, c.rgb()) return img