diff options
author | rcoh <rcoh@mit.edu> | 2010-12-15 00:18:24 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2010-12-15 00:18:24 -0500 |
commit | a89c772cd64c6790906734f7128947e0f453c7e3 (patch) | |
tree | 250e0b0d235e1215fa7b40fcfd24b74028ccf643 /util/ColorOps.py | |
parent | 8cecf83f16fcdec5b3ee68cc40c2b360e0f845d0 (diff) |
About halfway done with the Util cleanup. Some stuff left to do with scoping etc.
Diffstat (limited to 'util/ColorOps.py')
-rw-r--r-- | util/ColorOps.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/util/ColorOps.py b/util/ColorOps.py new file mode 100644 index 0000000..b0d64a7 --- /dev/null +++ b/util/ColorOps.py @@ -0,0 +1,11 @@ +import random +def randomColor(): + return [random.randint(0,255) for i in range(3)] +def chooseRandomColor(colorList): + return random.choice(colorList) +def safeColor(c): + return [min(channel,255) for channel in c] +def combineColors(c1,c2): + return safeColor([c1[i]+c2[i] for i in range(min(len(c1),len(c2)))]) +def multiplyColor(color, percent): + return safeColor([channel*(percent) for channel in color]) |