1 import random
2 import colorsys
3 from util.TimeOps import Stopwatch
5 return [random.randint(0,255) for i in range(3)]
6
8 """Given a list of colors, pick one at random"""
9 return random.choice(colorList)
11 """Ensures that a color is valid"""
12 c[0] = c[0] if c[0] < 255 else 255
13 c[1] = c[1] if c[1] < 255 else 255
14 c[2] = c[2] if c[2] < 255 else 255
15
16
17 return c
18
20 result = [0,0,0]
21 for c in colors:
22 result[0] += c[0]
23 result[1] += c[1]
24 result[2] += c[2]
25 return safeColor(result)
26
28 return safeColor([channel*(percent) for channel in color])
29
31 rgb[0] = int(rgb[0]*256 + .5)
32 rgb[1] = int(rgb[1]*256 + .5)
33 rgb[2] = int(rgb[2]*256 + .5)
34 return safeColor(rgb)
35
37 hue = random.random()
38 sat = random.random()/2.0 + .5
39 val = 1.0
40 hue, sat, val = colorsys.hsv_to_rgb(hue, sat, val)
41 ret = [hue, sat, val]
42 return floatToIntColor(ret)
43
47