def __init__(self, name, color0=QColor("black"), color1=QColor("white"), alpha=(1, 1)): QObject.__init__(self) self.name = name # color is either specified as one argument (which should then be a [3,n] or [4,n] array), # or as two QColors orstring names. if isinstance(color0, (list, tuple)): self._rgb = numpy.array(color0) if self._rgb.shape[1] != 3 or self._rgb.shape[0] < 2: raise TypeError( "expected [N,3] (N>=2) array as first argument") else: if isinstance(color0, str): color0 = QColor(color0) if isinstance(color1, str): color1 = QColor(color1) self._rgb = numpy.array([[ color0.red(), color0.green(), color0.blue() ], [color1.red(), color1.green(), color1.blue()]]) / 255. self._rgb_arg = numpy.arange( self._rgb.shape[0]) / (self._rgb.shape[0] - 1.0) # alpha array self._alpha = numpy.array(alpha).astype(float) self._alpha_arg = numpy.arange(len(alpha)) / (len(alpha) - 1.0) # background brush self._brush = None
def getColorDesc(_colorTag, outputAlpha=False): if _colorTag is None: return QColor(Qt.yellow), "#FFFF00" colorTag = _colorTag.lower() if (colorTag == "red"): qtColor = QColor(Qt.red) elif (colorTag == "green"): qtColor = QColor(Qt.green) elif (colorTag == "blue"): qtColor = QColor(Qt.blue) elif (colorTag == "cyan"): qtColor = QColor(Qt.cyan) elif (colorTag == "darkGray"): qtColor = QColor(Qt.darkGray) elif (colorTag == "magenta"): qtColor = QColor(Qt.magenta) elif (colorTag[0] == "#"): colorHexDesc = colorTag qtColor = hexColorStrToQtColor(colorTag, outputAlpha) else: qtColor = QColor(Qt.yellow) colorHexDesc = "#FFFF00" if qtColor is not None: colorHexDesc = "#%02x%02x%02x" % (qtColor.red(), qtColor.green(), qtColor.blue()) # LOG.info("qtColor = {}, colorHexDesc = {}".format(qtColor, colorHexDesc)) return qtColor, colorHexDesc
def __init__(self, name, color0=QColor("black"), color1=QColor("white"), alpha=(1, 1)): QObject.__init__(self) self.name = name # color is either specified as one argument (which should then be a [3,n] or [4,n] array), # or as two QColors orstring names. if isinstance(color0, (list, tuple)): self._rgb = numpy.array(color0) if self._rgb.shape[1] != 3 or self._rgb.shape[0] < 2: raise TypeError("expected [N,3] (N>=2) array as first argument") else: if isinstance(color0, str): color0 = QColor(color0) if isinstance(color1, str): color1 = QColor(color1) self._rgb = numpy.array([[color0.red(), color0.green(), color0.blue()], [color1.red(), color1.green(), color1.blue()]]) / 255. self._rgb_arg = numpy.arange(self._rgb.shape[0]) / (self._rgb.shape[0] - 1.0) # alpha array self._alpha = numpy.array(alpha).astype(float) self._alpha_arg = numpy.arange(len(alpha)) / (len(alpha) - 1.0) # background brush self._brush = None