Python colorsys.rgb_to_yiq() Examples
The following are 8
code examples of colorsys.rgb_to_yiq().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
colorsys
, or try the search function
.
Example #1
Source File: test_colorsys.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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))
Example #2
Source File: test_colorsys.py From ironpython3 with Apache License 2.0 | 6 votes |
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))
Example #3
Source File: test_colorsys.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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))
Example #4
Source File: colors.py From rekall with GNU General Public License v2.0 | 5 votes |
def RGBToYIQ(red, green, blue): return colorsys.rgb_to_yiq( old_div(float(red), 0xff), old_div(float(green), 0xff), old_div(float(blue), 0xff))
Example #5
Source File: test_colorsys.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)) )
Example #6
Source File: uistuff.py From pychess with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: test_colorsys.py From ironpython3 with Apache License 2.0 | 5 votes |
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)) )
Example #8
Source File: test_colorsys.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)) )