aboutsummaryrefslogtreecommitdiff
path: root/util/ColorOps.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-01-27 16:50:59 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-01-27 16:50:59 -0500
commit5fb3ea060025241105dc8e9a174513c112f9a133 (patch)
treee98b1b3eab0b05b0e518b08cbab086d224fd9250 /util/ColorOps.py
parent5d29906fff79bc6e4ba83be7028e1380a0014d21 (diff)
A metric $#%$-ton of changes. Added doc-strings to EVERYTHING. Phew. Fixed a massive bug that
increases performance in by up to a factor of 60. A bunch of new behaviors for the class.
Diffstat (limited to 'util/ColorOps.py')
-rw-r--r--util/ColorOps.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/ColorOps.py b/util/ColorOps.py
index 143444f..037957a 100644
--- a/util/ColorOps.py
+++ b/util/ColorOps.py
@@ -2,13 +2,17 @@ import random
from util.TimeOps import Stopwatch
def randomColor():
return [random.randint(0,255) for i in range(3)]
+
def chooseRandomColor(colorList):
+ """Given a list of colors, pick one at random"""
return random.choice(colorList)
def safeColor(c):
+ """Ensures that a color is valid"""
c[0] = c[0] if c[0] < 255 else 255
c[1] = c[1] if c[1] < 255 else 255
c[2] = c[2] if c[2] < 255 else 255
return c
+
def combineColors(colors):
result = [0,0,0]
for c in colors:
@@ -16,5 +20,6 @@ def combineColors(colors):
result[1] += c[1]
result[2] += c[2]
return safeColor(result)
+
def multiplyColor(color, percent):
return safeColor([channel*(percent) for channel in color])