parent
49c372a2d5
commit
8277ecec34
30
color.py
30
color.py
|
@ -1,4 +1,5 @@
|
|||
import curses
|
||||
import itertools
|
||||
|
||||
colors = {}
|
||||
_colors = []
|
||||
|
@ -32,27 +33,24 @@ def add_color(name, value, abbrev):
|
|||
# assign every RGB triple (0-5) to one of six basic colors (red, yellow, green,
|
||||
# cyan, blue, magenta) based on some semi-arbitrary rules i came up with.
|
||||
def iter256():
|
||||
for r in xrange(0, 6):
|
||||
for g in xrange(0, 6):
|
||||
for b in xrange(0, 6):
|
||||
#if r >= 3 and g >= 3 and b >= 3: name = 'white'
|
||||
#elif r >= g and g > b: name = 'yellow'
|
||||
if r >= g and g > b: name = 'yellow'
|
||||
elif r >= b and b - g > 1: name = 'magenta'
|
||||
ns = range(0, 6)
|
||||
for r, g, b in itertools.product(ns, ns, ns):
|
||||
if r >= g and g > b: name = 'yellow'
|
||||
elif r >= b and b - g > 1: name = 'magenta'
|
||||
|
||||
elif b >= g and g - r > 2: name = 'cyan'
|
||||
elif b >= r and r > g: name = 'magenta'
|
||||
elif b >= g and g - r > 2: name = 'cyan'
|
||||
elif b >= r and r > g: name = 'magenta'
|
||||
|
||||
elif g >= r and r - b > 2: name = 'yellow'
|
||||
elif g >= b and b - r > 1: name = 'cyan'
|
||||
elif g >= r and r - b > 2: name = 'yellow'
|
||||
elif g >= b and b - r > 1: name = 'cyan'
|
||||
|
||||
elif r > b and r > g: name = 'red'
|
||||
elif g > b and g > r: name = 'green'
|
||||
elif b > r and b > g: name = 'blue'
|
||||
elif r > b and r > g: name = 'red'
|
||||
elif g > b and g > r: name = 'green'
|
||||
elif b > r and b > g: name = 'blue'
|
||||
|
||||
else: continue
|
||||
else: continue
|
||||
|
||||
yield (name, r, g, b)
|
||||
yield (name, r, g, b)
|
||||
raise StopIteration
|
||||
|
||||
# if we can support 256 colors, create all of the color names and map them to
|
||||
|
|
Loading…
Reference in New Issue