From 4d62e1152241854ab864142d827d735d84405078 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sat, 12 Feb 2011 15:59:59 -0500 Subject: Modified the test code to automatically pick up new tests. Just add your test file to tests/__init__.py. Fixed a bug in ZigZagLayout. Added the BehaviorQuerySystem to allow querying on behaviors. Added the "ModulateColor" behavior which will continually shift a color along the HSV plane. Added TestBQS to test the behavior query system. Modified Behavior to have a getLastOutput and setLastOutput method. --- behaviors/ColorShift.py | 16 ++++++++++++++++ behaviors/ModulateColor.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 behaviors/ColorShift.py create mode 100644 behaviors/ModulateColor.py (limited to 'behaviors') diff --git a/behaviors/ColorShift.py b/behaviors/ColorShift.py new file mode 100644 index 0000000..f185b40 --- /dev/null +++ b/behaviors/ColorShift.py @@ -0,0 +1,16 @@ +import util.ColorOps as colorOps +from operationscore.Behavior import * +import colorsys +class ColorShift(Behavior): + def processResponse(self, sensor, recurs): + ret = [] + for data in sensor: + if not 'HSV' in data: + data['HSV'] = list(colorsys.rgb_to_hsv(*data['Color'])) + + data['HSV'][0] += .01 + if data['HSV'][0] >= 360: + data['HSV'][0] = 0 + data['Color'] = colorsys.hsv_to_rgb(*data['HSV']) + ret.append(data) + return (ret,[]) diff --git a/behaviors/ModulateColor.py b/behaviors/ModulateColor.py new file mode 100644 index 0000000..904526e --- /dev/null +++ b/behaviors/ModulateColor.py @@ -0,0 +1,16 @@ +import util.ColorOps as colorOps +from operationscore.Behavior import * +import colorsys +class ColorShift(Behavior): + def processResponse(self, sensor, recurs): + ret = [] + for data in sensor: + if not 'HSV' in data: + data['HSV'] = colorsys.rgb_to_hsv(data['Color']) + + data['HSV'][0] += .5 + if data['HSV'][0] >= 360: + data['HSV'][0] = 0 + data['Color'] = colorsys.hsv_to_rgb(data['HSV']) + ret.append(data) + return (ret,[]) -- cgit v1.2.3