本文整理汇总了Python中PySide.QtGui.QColor.setRgb方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.setRgb方法的具体用法?Python QColor.setRgb怎么用?Python QColor.setRgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.setRgb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_metallic_roughness_map
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setRgb [as 别名]
def _create_metallic_roughness_map(self, metal_map, rough_map):
metal = QImage(metal_map)
rough = QImage(rough_map)
metal_pixel = QColor()
metal = metal.convertToFormat(QImage.Format_RGB32);
rough = rough.convertToFormat(QImage.Format_RGB32);
metal_uchar_ptr = metal.bits()
rough_uchar_ptr = rough.bits()
if (not metal.width() == rough.width()
or not metal.height() == rough.height()):
raise RuntimeError("Error processing material: {}. Metallic map and roughness map must have same dimensions.".format(self.maya_node))
width = metal.width();
height = metal.height();
i = 0
for y in range(height):
for x in range(width):
metal_color = struct.unpack('I', metal_uchar_ptr[i:i+4])[0]
rough_color = struct.unpack('I', rough_uchar_ptr[i:i+4])[0]
metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color))
metal_uchar_ptr[i:i+4] = struct.pack('I', metal_pixel.rgb())
i+=4
output = ExportSettings.out_dir + "/"+self.name+"_metalRough.jpg"
return output, metal
示例2: LightWidget
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setRgb [as 别名]
class LightWidget(QtGui.QWidget):
def __init__(self):
super(LightWidget, self).__init__()
self.color = QColor()
self.last_is_red = True
self.set_red()
def set_red(self):
self.color.setRgb(255, 0, 0)
if not self.last_is_red:
try:
self.update()
except Exception:
pass
self.last_is_red = True
def set_green(self):
self.color.setRgb(0, 255, 0)
if self.last_is_red:
try:
self.update()
except Exception:
pass
self.last_is_red = False
def paintEvent(self, e):
qp = QtGui.QPainter()
qp.begin(self)
self.drawWidget(qp)
qp.end()
def drawWidget(self, qp):
size = self.size()
radx = size.width()
rady = size.height()
dot = min(radx, rady) / 2
pen = QPen()
pen.setWidth(dot)
# pen.setStyle(Qt.SolidLine)
pen.setBrush(self.color)
# pen.setCapStyle(Qt.RoundCap)
# pen.setJoinStyle(Qt.RoundJoin)
qp.setPen(pen)
qp.drawLine(dot, dot, dot, dot)
示例3: testQColorToTuple
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import setRgb [as 别名]
def testQColorToTuple(self):
c = QColor(0, 0, 255)
c.setRgb(1, 2, 3)
self.assertEqual((1, 2, 3, 255), c.toTuple())