本文整理汇总了Python中PySide.QtGui.QColor类的典型用法代码示例。如果您正苦于以下问题:Python QColor类的具体用法?Python QColor怎么用?Python QColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_metallic_roughness_map
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: loadContour
def loadContour(self, contourData):
logging.debug("In CPRAction::loadContour()")
scenes = self._ilsa.scenes()
contour = CPRContour(scenes, self._ilsa, self.cprClosed)
for scene in scenes:
if contourData["sceneId"] == scene.id:
contour.scene = scene
elif contourData["panoramicSceneId"] == scene.id:
contour.setPanoramicPlane(scene.parent)
elif contourData["transversalSceneId"] == scene.id:
contour.setTransversalPlane(scene.parent)
self.propertiesAction.addContour(contour)
contour.loadPoints(contourData["points"])
lc = contourData["lineColor"]
alc = contourData["actualLineColor"]
ts = contourData["transversalSize"]
lineColor = QColor.fromRgbF(lc[0], lc[1], lc[2])
actualLineColor = QColor.fromRgbF(alc[0], alc[1], alc[2])
self.propertiesAction.changeLineColor(lineColor)
self.propertiesAction.changeActualLineColor(actualLineColor)
contour.setTransversalSize(ts)
self.propertiesAction.slotActionVisible(contourData["visible"])
self.propertiesAction.slotActionLock(contourData["locked"])
self.propertiesAction.lock.setChecked(contourData["locked"])
示例3: paintEvent
def paintEvent(self, ev):
if self.isEnabled():
color = self.color
colorBorder = [0.4, 0.4, 0.4]
else:
color = [0.8, 0.8, 0.8]
colorBorder = [0.7, 0.7, 0.7]
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.setRenderHint(QPainter.HighQualityAntialiasing)
if self.isChecked():
pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
pen.setWidth(2.0)
else:
pen = QPen(QColor.fromRgbF(colorBorder[0], colorBorder[1], colorBorder[2]))
pen.setWidth(1.0)
size = self.size()
sizeCircle = 12.0
x = size.width() / 2.0 - (sizeCircle / 2.0)
y = size.height() / 2.0 - (sizeCircle / 2.0)
rect = QRectF(x, y, sizeCircle, sizeCircle)
painter.setPen(pen)
painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
painter.drawEllipse(rect)
示例4: fromStr
def fromStr(name, a=255):
if name in _Colorizer.__colorTable:
c = QColor(_Colorizer.__colorTable[name])
else:
c = QColor(Qt.transparent)
c.setAlpha(a)
return c
示例5: __init__
def __init__(self, size, dynamic, controller):
layer.__init__(self,size,dynamic)
self.controller = controller
self.ready = False
dotColor = QColor()
dotColor.setNamedColor(self.controller.svgLayer.svg.dotPrototype.getAttribute('fill'))
dotColor.setAlphaF(float(self.controller.svgLayer.svg.dotPrototype.getAttribute('fill-opacity')))
self.dotColors = []
i = 0
while i <= 1.0:
self.dotColors.append(QColor.fromRgbF(dotColor.redF(),dotColor.greenF(),dotColor.blueF(),i))
i += dotColor.alphaF()
self.dotWidth = self.controller.svgLayer.svg.dotPrototype.width()
self.dotHeight = self.controller.svgLayer.svg.dotPrototype.height()
self.halfDotWidth = self.dotWidth/2
self.halfDotHeight = self.dotHeight/2
self.xoffset = self.controller.scatterBounds[0]-self.halfDotWidth
self.yoffset = self.controller.scatterBounds[3]-self.halfDotHeight
self.xNonNumeric = (self.controller.svgLayer.svg.xNonNumericIcon.left() + self.controller.svgLayer.svg.xNonNumericIcon.right())/2 - self.halfDotWidth
self.yNonNumeric = (self.controller.svgLayer.svg.yNonNumericIcon.top() + self.controller.svgLayer.svg.yNonNumericIcon.bottom())/2 - self.halfDotHeight
示例6: _set_pixmap_from_roi
def _set_pixmap_from_roi(self, roi):
if roi.visible:
color = _display_color(roi.color, self.selected)
else:
color = QColor(Qt.transparent)
self.pixmap = _ndarray_to_arraypixmap(roi.mask[self.slicer.slc.view_slice], color.toTuple())
self.pixmapitem.setPixmap(self.pixmap)
self.pixmapitem.setZValue(_foreground_roi_z if self.selected else _background_roi_z)
示例7: setBaseColor
def setBaseColor(newcolor):
StyleHelper.requestedBaseColor = newcolor
color = QColor()
color.setHsv(newcolor.hue(), newcolor.saturation() * 0.7, 64 + newcolor.value() / 3)
if color.isValid() and color != StyleHelper.baseColor:
StyleHelper.baseColor = color
for w in QApplication.topLevelWidgets():
w.update()
示例8: _fade
def _fade(self, lineno):
cursor = self._get_line_cursor(lineno)
fmt = cursor.charFormat()
color=QColor('black')
color.setAlphaF(0.5)
fmt.setForeground(color)
cursor.beginEditBlock()
cursor.mergeCharFormat(fmt)
cursor.endEditBlock()
示例9: _init_ui
def _init_ui(self, txt):
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
pal = QPalette()
color = QColor()
color.setNamedColor(self._window_bgcolor)
color.setAlpha(255 * self._opacity)
pal.setColor(QPalette.Background, color)
self.setAutoFillBackground(True)
self.setPalette(pal)
wm, hm = 5, 5
spacing = 8
layout = QVBoxLayout()
layout.setSpacing(spacing)
layout.setContentsMargins(wm, hm, wm, hm)
nlines, ts = self._generate_text(txt)
qlabel = QLabel('\n'.join(ts))
ss = 'QLabel {{color: {}; font-family:{}, sans-serif; font-size: {}px}}'.format(self._color,
self._font,
self._fontsize)
qlabel.setStyleSheet(ss)
layout.addWidget(qlabel)
hlabel = QLabel('double click to dismiss')
hlabel.setStyleSheet('QLabel {font-size: 10px}')
hlayout = QHBoxLayout()
hlayout.addStretch()
hlayout.addWidget(hlabel)
hlayout.addStretch()
layout.addLayout(hlayout)
self.setLayout(layout)
font = QFont(self._font, self._fontsize)
fm = QFontMetrics(font)
pw = max([fm.width(ti) for ti in ts])
ph = (fm.height() + 2) * nlines
w = pw + wm * 2
h = ph + (hm + spacing + 1) * 2
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.setFixedWidth(w)
self.setFixedHeight(h)
self.setMask(mask(self.rect(), 10))
示例10: routeFinished
def routeFinished(self):
if not self.routeReply.routes():
return
route = QGeoMapRouteObject(self.routeReply.routes()[0])
routeColor = QColor(Qt.blue)
routeColor.setAlpha(127)
pen = QPen(routeColor)
pen.setWidth(7)
pen.setCosmetic(True)
pen.setCapStyle(Qt.RoundCap)
route.setPen(pen)
self.mapWidget.addMapObject(route)
示例11: startNewLineCollection
def startNewLineCollection(self):
self.lineCollections.append(LineCollection())
self.openCollectionIdx += 1
newColor = QColor()
# http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
'''
rand = random.random()
rand += 0.618033988749895
rand %= 1
'''
phi = 0.618033988749895
hue = self.openCollectionIdx * phi - floor(self.openCollectionIdx * phi)
newColor.setHsv(int(hue*256), 120 + int(random.random()*(240-120+1)), 242)
self.colors.append(newColor)
示例12: drawPolygon
def drawPolygon(self):
path = [mark.coordinate() for mark in self.markerObjects]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
polygon = QGeoMapPolygonObject()
polygon.setPen(pen)
fill = QColor(Qt.black)
fill.setAlpha(65)
polygon.setBrush(QBrush(fill))
polygon.setPath(path)
self.mapWidget.addMapObject(polygon)
示例13: syntax_format
def syntax_format(color, style=''):
"""Return a QTextCharFormat with the given attributes.
"""
_color = QColor()
_color.setNamedColor(color)
_format = QTextCharFormat()
_format.setForeground(_color)
if 'bold' in style:
_format.setFontWeight(QFont.Bold)
if 'italic' in style:
_format.setFontItalic(True)
return _format
示例14: __init__
def __init__(self, size, dynamic, controller, prototypeLine, opaqueBack = False):
layer.__init__(self,size,dynamic)
self.controller = controller
self.points = set()
if opaqueBack:
self.backgroundColor = Qt.white
else:
self.backgroundColor = Qt.transparent
lineColor = QColor()
lineColor.setNamedColor(prototypeLine.getAttribute('stroke'))
lineColor.setAlphaF(float(prototypeLine.getAttribute('stroke-opacity')))
self.pen = QPen(lineColor)
self.pen.setWidthF(prototypeLine.getAttribute('stroke-width'))
示例15: drawRect
def drawRect(self):
if len(self.markerObjects) < 2:
return
p1, p2 = self.markerObjects[:2]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
fill = QColor(Qt.black)
fill.setAlpha(65)
rectangle = QGeoMapRectangleObject(p1.coordinate(), p2.coordinate())
rectangle.setPen(pen)
rectangle.setBrush(QBrush(fill))
self.mapWidget.addMapObject(rectangle)