本文整理汇总了Python中PySide.QtGui.QColor.alphaF方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.alphaF方法的具体用法?Python QColor.alphaF怎么用?Python QColor.alphaF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.alphaF方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QColorGetTest
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import alphaF [as 别名]
class QColorGetTest(unittest.TestCase):
def setUp(self):
self.color = QColor(20, 40, 60, 80)
def testGetRgb(self):
self.assertEqual(self.color.getRgb(), (20, 40, 60, 80))
def testGetHslF(self):
hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255)
hsla = hls[0], hls[2], hls[1], self.color.alphaF()
for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems
self.assert_(x - y < 1/100000.0)
def testGetHsv(self):
hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255)
hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha()
self.assertEqual(self.color.getHsv(), hsva)
def testGetCmyk(self): # not supported by colorsys
self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80))
def testGetCmykF(self): # not supported by colorsys
for x, y in zip(self.color.getCmykF(), (170/255.0, 85/255.0, 0, 195/255.0, 80/255.0)):
self.assert_(x - y < 1/10000.0)
示例2: __init__
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import alphaF [as 别名]
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