plugin.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:LIFX_Controller 作者: autolog 项目源码 文件源码
def actionConfigSetColorSwatchRGB(self, hue, saturation, value):
        self.methodTracer.threaddebug(u"CLASS: Plugin")

        # hue, saturation and value are integers in the range 0 - 65535
        hue = float(hue) / 65535.0
        value = float(value) / 65535.0
        saturation = float(saturation) / 65535.0

        red, green, blue = colorsys.hsv_to_rgb(hue, saturation, value)

        red   = int(round(float(red * 255.0)))
        green = int(round(float(green * 255.0)))
        blue  = int(round(float(blue * 255.0)))

        rgb = [red,green,blue]
        rgbHexVals = []
        for byteLevel in rgb:
            if byteLevel < 0:
                byteLevel = 0
            elif byteLevel > 255:
                byteLevel = 255
            rgbHexVals.append("%02X" % byteLevel)
        return ' '.join(rgbHexVals)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号