aboutsummaryrefslogtreecommitdiff
path: root/behaviors
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-12 15:59:59 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-12 15:59:59 -0500
commit4d62e1152241854ab864142d827d735d84405078 (patch)
tree2589c6a37721e1b8362c8e8c6a580c8c185b2f86 /behaviors
parentb45b9079c5decd720d8275378bb0d6dc172c6234 (diff)
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.
Diffstat (limited to 'behaviors')
-rw-r--r--behaviors/ColorShift.py16
-rw-r--r--behaviors/ModulateColor.py16
2 files changed, 32 insertions, 0 deletions
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,[])