diff options
author | rcoh <rcoh@mit.edu> | 2010-12-29 13:08:22 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2010-12-29 13:08:22 -0500 |
commit | 3036cc366e992c451d783635cbe9a50a606c8fce (patch) | |
tree | c68805965a6dcd5c99d863f3c0c858a203a5029a /util | |
parent | f9aeaf10e3c9077504a78374640e79415734546b (diff) |
early.
Diffstat (limited to 'util')
-rw-r--r-- | util/ColorOps.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/util/ColorOps.py b/util/ColorOps.py index b0d64a7..9da27fb 100644 --- a/util/ColorOps.py +++ b/util/ColorOps.py @@ -1,4 +1,5 @@ import random +from util.TimeOps import Stopwatch def randomColor(): return [random.randint(0,255) for i in range(3)] def chooseRandomColor(colorList): @@ -8,4 +9,10 @@ def safeColor(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]) + return safeColor([fastMultiply(channel, percent, 1) for channel in color]) + +def fastMultiply(value, mult, acc): + if type(mult) == type(int(5)): + return value*mult + return int(value)*int(mult*10**acc)*10**(-acc) + |