def updateColor(self, color): """Sets the top right color of the panel.""" color = QColor(color) color.setAlpha(255) self._color = color self._image = QImage(self.size(), QImage.Format_ARGB32) painter = SmoothPainter(self._image) # Render top right corner # Choose brightest, most saturated color for the given hue. Undefined hues (greys) should default to red hue. h = max(0, color.hsvHue()) color_full = QColor.fromHsv(h, 255, 255) painter.fillRect(self.rect(), color_full) # Create vertical shading gradient = QLinearGradient(0, 0, self.width(), 0) gradient.setColorAt(0, Qt.white) gradient.setColorAt(1, QColor.fromHslF(0.055, 0.42, 0.65, 0)) painter.fillRect(self.rect(), gradient) # Create horizontal shading gradient = QLinearGradient(0, self.height(), 0, 0) gradient.setColorAt(1, QColor.fromHslF(0.055, 0.42, 0.65, 0)) gradient.setColorAt(0, Qt.black) painter.fillRect(self.rect(), gradient) self._createSkinToneIndicator(painter) painter.end() w, h = self.width(), self.height() _, s, v, _ = color.getHsvF() x, y = s * w, (1 - v) * h self._pointerPos = QPoint(x, y) self.update()