當前位置: 首頁>>代碼示例>>Python>>正文


Python colorsys.yiq_to_rgb方法代碼示例

本文整理匯總了Python中colorsys.yiq_to_rgb方法的典型用法代碼示例。如果您正苦於以下問題:Python colorsys.yiq_to_rgb方法的具體用法?Python colorsys.yiq_to_rgb怎麽用?Python colorsys.yiq_to_rgb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在colorsys的用法示例。


在下文中一共展示了colorsys.yiq_to_rgb方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_yiq_values

# 需要導入模塊: import colorsys [as 別名]
# 或者: from colorsys import yiq_to_rgb [as 別名]
def test_yiq_values(self):
        values = [
            # rgb, yiq
            ((0.0, 0.0, 0.0), (0.0, 0.0, 0.0)), # black
            ((0.0, 0.0, 1.0), (0.11, -0.3217, 0.3121)), # blue
            ((0.0, 1.0, 0.0), (0.59, -0.2773, -0.5251)), # green
            ((0.0, 1.0, 1.0), (0.7, -0.599, -0.213)), # cyan
            ((1.0, 0.0, 0.0), (0.3, 0.599, 0.213)), # red
            ((1.0, 0.0, 1.0), (0.41, 0.2773, 0.5251)), # purple
            ((1.0, 1.0, 0.0), (0.89, 0.3217, -0.3121)), # yellow
            ((1.0, 1.0, 1.0), (1.0, 0.0, 0.0)), # white
            ((0.5, 0.5, 0.5), (0.5, 0.0, 0.0)), # grey
        ]
        for (rgb, yiq) in values:
            self.assertTripleEqual(yiq, colorsys.rgb_to_yiq(*rgb))
            self.assertTripleEqual(rgb, colorsys.yiq_to_rgb(*yiq)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_colorsys.py

示例2: YIQToRGB

# 需要導入模塊: import colorsys [as 別名]
# 或者: from colorsys import yiq_to_rgb [as 別名]
def YIQToRGB(y, i, q):
    red, green, blue = colorsys.yiq_to_rgb(y, i, q)
    return int(red * 0xff), int(green * 0xff), int(blue * 0xff)


# Text-color heuristics: 
開發者ID:google,項目名稱:rekall,代碼行數:8,代碼來源:colors.py

示例3: test_yiq_roundtrip

# 需要導入模塊: import colorsys [as 別名]
# 或者: from colorsys import yiq_to_rgb [as 別名]
def test_yiq_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.yiq_to_rgb(*colorsys.rgb_to_yiq(*rgb))
                    ) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:test_colorsys.py

示例4: genColor

# 需要導入模塊: import colorsys [as 別名]
# 或者: from colorsys import yiq_to_rgb [as 別名]
def genColor(n, startpoint=0):
    assert n >= 1
    # This splits the 0 - 1 segment in the pizza way
    hue = (2 * n - 1) / (2.**(n - 1).bit_length()) - 1
    hue = (hue + startpoint) % 1
    # We set saturation based on the amount of green, scaled to the interval
    # [0.6..0.8]. This ensures a consistent lightness over all colors.
    rgb = colorsys.hsv_to_rgb(hue, 1, 1)
    rgb = colorsys.hsv_to_rgb(hue, 1, (1 - rgb[1]) * 0.2 + 0.6)
    # This algorithm ought to balance colors more precisely, but it overrates
    # the lightness of yellow, and nearly makes it black
    # yiq = colorsys.rgb_to_yiq(*rgb)
    # rgb = colorsys.yiq_to_rgb(.125, yiq[1], yiq[2])
    return rgb 
開發者ID:pychess,項目名稱:pychess,代碼行數:16,代碼來源:uistuff.py

示例5: parse_yiq

# 需要導入模塊: import colorsys [as 別名]
# 或者: from colorsys import yiq_to_rgb [as 別名]
def parse_yiq(data):
    """
    Parses YIQ color bytes and returns fill style list.
    """
    y = ord(data[0]) / 255.0
    i = 2.0 * ord(data[1]) / 255.0 - 1.0
    q = 2.0 * ord(data[2]) / 255.0 - 1.0
    r, g, b = yiq_to_rgb(y, i, q)
    return [uc2const.COLOR_RGB, [r, g, b], 1.0, ''] 
開發者ID:sk1project,項目名稱:uniconvertor,代碼行數:11,代碼來源:cdr_utils.py

示例6: set_v1_colors

# 需要導入模塊: import colorsys [as 別名]
# 或者: from colorsys import yiq_to_rgb [as 別名]
def set_v1_colors(self):
        rclr = self.cmx_model.chunk_map[cmx_const.RCLR_ID]
        colors = rclr.data['colors']
        for model, _pal, vals in colors:
            model = cmx_const.COLOR_MODEL_MAP.get(model, cmx_const.CMX_INVALID)
            clr = sk2const.CMYK_BLACK
            if model == cmx_const.CMX_CMYK:
                vals = cms.val_100_to_dec(vals)
                clr = [uc2const.COLOR_CMYK, vals, 1.0, '']
            elif model == cmx_const.CMX_CMYK255:
                vals = cms.val_255_to_dec(vals)
                clr = [uc2const.COLOR_CMYK, vals, 1.0, '']
            elif model == cmx_const.CMX_CMY:
                vals = cms.val_255_to_dec(vals) + (0.0,)
                clr = [uc2const.COLOR_CMYK, vals, 1.0, '']
            elif model == cmx_const.CMX_RGB:
                vals = cms.val_255_to_dec(vals)
                clr = [uc2const.COLOR_RGB, vals, 1.0, '']
            elif model == cmx_const.CMX_HSB:
                first = vals[0] * 255 + vals[1] \
                    if self.rifx else vals[0] + vals[1] * 255
                vals = (first / 360.0, vals[2] / 255.0, vals[3] / 255.0)
                r, g, b = colorsys.hsv_to_rgb(*vals)
                clr = [uc2const.COLOR_RGB, [r, g, b], 1.0, '']
            elif model == cmx_const.CMX_HLS:
                first = vals[0] * 255 + vals[1] \
                    if self.rifx else vals[0] + vals[1] * 255
                vals = (first / 360.0, vals[2] / 255.0, vals[3] / 255.0)
                r, g, b = colorsys.hls_to_rgb(*vals)
                clr = [uc2const.COLOR_RGB, [r, g, b], 1.0, '']
            elif model == cmx_const.CMX_BW:
                vals = [1.0, 1.0, 1.0] if vals[0] else [0.0, 0.0, 0.0]
                clr = [uc2const.COLOR_RGB, vals, 1.0, '']
            elif model == cmx_const.CMX_GRAY:
                clr = [uc2const.COLOR_GRAY, [vals[0] / 255.0, ], 1.0, '']
            elif model == cmx_const.CMX_YIQ255:
                y = vals[0] / 255.0
                i = 2.0 * vals[1] / 255.0 - 1.0
                q = 2.0 * vals[2] / 255.0 - 1.0
                r, g, b = colorsys.yiq_to_rgb(y, i, q)
                clr = [uc2const.COLOR_RGB, [r, g, b], 1.0, '']
            elif model == cmx_const.CMX_LAB:
                vals = cms.val_255_to_dec(vals)
                clr = [uc2const.COLOR_LAB, vals, 1.0, '']

            self._colors.append(clr) 
開發者ID:sk1project,項目名稱:uniconvertor,代碼行數:48,代碼來源:cmx_to_sk2.py


注:本文中的colorsys.yiq_to_rgb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。