From 3036cc366e992c451d783635cbe9a50a606c8fce Mon Sep 17 00:00:00 2001 From: rcoh Date: Wed, 29 Dec 2010 13:08:22 -0500 Subject: early. --- util/ColorOps.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'util') 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) + -- cgit v1.2.3