Add "Random" for 255 colors mode

Thus we can specify "random" for 8 colors mode, or "Random" for 255 colors.
This commit is contained in:
nojhan 2013-03-03 09:11:40 +01:00
commit eba7c1462d
2 changed files with 10 additions and 2 deletions

View file

@ -50,7 +50,7 @@ def colorin( text, color = "red", style = "normal" ):
stop = "\033[0m"
# Convert the style code
if style == "random":
if style == "random" or style == "Random":
style = random.choice(list(styles.keys()))
else:
assert( style in styles)
@ -62,6 +62,11 @@ def colorin( text, color = "red", style = "normal" ):
color_code = random.choice(list(colors.values()))
color_code = str( 30 + color_code )
elif color == "Random":
mode = 256
color_nb = random.randint(0,255)
color_code = str( color_nb )
elif color == "rainbow":
global rainbow_idx
mode = 8