diff options
author | rcoh <rcoh@mit.edu> | 2011-01-29 21:05:59 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2011-01-29 21:05:59 -0500 |
commit | 9f69f7a2e174da12e6b2554c4270b5cadc52ff23 (patch) | |
tree | 503f63959459fd91cd1c170a390e916b85499a01 /util | |
parent | b42cab93f90760eaf3f8aac01c2ab41c1a5b1176 (diff) | |
parent | da934a838305bab72bd12dcd2b83e689f7c1cc3f (diff) |
Merge branch 'fridaydemo' of https://github.com/smootlight2/SmootLight into smootlight2-fridaydemo
Diffstat (limited to 'util')
-rw-r--r-- | util/ColorOps.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util/ColorOps.py b/util/ColorOps.py index e384605..4b1162a 100644 --- a/util/ColorOps.py +++ b/util/ColorOps.py @@ -1,4 +1,5 @@ import random +import colorsys from util.TimeOps import Stopwatch def randomColor(): return [random.randint(0,255) for i in range(3)] @@ -25,3 +26,17 @@ def combineColors(colors): def multiplyColor(color, percent): return safeColor([channel*(percent) for channel in color]) + +def floatToIntColor(rgb): + rgb[0] = int(rgb[0]*256 + .5) + rgb[1] = int(rgb[1]*256 + .5) + rgb[2] = int(rgb[2]*256 + .5) + return safeColor(rgb) + +def randomBrightColor(): + hue = random.random() + sat = random.random()/2.0 + .5 + val = 1.0 + hue, sat, val = colorsys.hsv_to_rgb(hue, sat, val) + ret = [hue, sat, val] + return floatToIntColor(ret) |