Esempio n. 1
0
 def emphasize(cls, color, value=10):
     '''
     @param: color QColor
     @param: value int
     @return: QColor
     '''
     ret = QColor()
     h, s, v, a = color.getHsv()
     if v < 75 + value:
         ret.setHsv(h, s, cls.CLAMP(85 + value, 85, 255), a)
         return ret
     if v > 200:
         if s > 30:
             h -= 5
             if h < 0:
                 h = 360 + h
             s = (s << 3) // 9
             v += value
             ret.setHsv(h, cls.CLAMP(s, 30, 255), cls.CLAMP(v, 0, 255), a)
             return ret
         if v > 230:
             ret.setHsv(h, s, cls.CLAMP(v - value, 0, 255), a)
             return ret
     if v > 128:
         ret.setHsv(h, s, cls.CLAMP(v + value, 0, 255), a)
     else:
         ret.setHsv(h, s, cls.CLAMP(v - value, 0, 255), a)
     return ret
Esempio n. 2
0
    def setBaseColor(self, newColor):
        '''
        @brief: Sets the base color and makes sure all top level widgets are updated
        @note: We try to ensure that the actual color used are within
            reasonable bounds while generating the actual baseColor
            from the import user request.
        @param: color QColor
        '''
        self._requestedBaseColor = newColor

        color = QColor()
        color.setHsv(newColor.hue(),
                     newColor.saturation() * 0.7, 64 + newColor.value() / 3)

        if color.isValid() and color != self._baseColor:
            self._baseColor = color
            for widget in QApplication.topLevelWidgets():
                widget.update()
Esempio n. 3
0
 def light(cls, color, value):
     '''
     @param: color QColor
     @param: value int
     @return: QColor
     '''
     h, s, v, a = color.getHsv()
     ret = QColor()
     if v < 255 - value:
         ret.setHsv(h, s, cls.CLAMP(v + value, 0, 255),
                    a)  # value could be negative
         return ret
     # psychovisual uplightning, i.e. shift hue and lower saturation
     if s > 30:
         h -= (value * 5 / 20)
         if h < 0:
             h = 400 + h
         s = cls.CLAMP((s << 3) / 9, 30, 255)
         ret.setHsv(h, s, 255, a)
         return ret
     else:  # hue shifting has no sense, half saturation (btw, white won't get brighter)
         ret.setHsv(h, s >> 1, 255, a)
     return ret