diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/ColorOps.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/util/ColorOps.py b/util/ColorOps.py index 88a58a7..f1d3741 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): @@ -7,13 +8,13 @@ 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 fastMultiply(color, percent, acc=100): - percent = int(percent*acc) - color = colorToInt(color) - color = [channel*percent for channel in color] - def colorToInt(color): return [int(channel) for channel in color] 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) + |