diff options
author | dxiao <dxiao@mit.edu> | 2011-02-20 16:18:43 -0500 |
---|---|---|
committer | dxiao <dxiao@mit.edu> | 2011-02-20 16:18:43 -0500 |
commit | 792dd4d7139f9080bf6d3d760efe763b8b3f60cc (patch) | |
tree | 7095fb17e533c9d29a531ea008b1a239f7383a8a | |
parent | c2874a0cefa410aca3fdd33ed701b16bac520440 (diff) |
Added LocationMask, which limits affected pixels to a specified region of the screen
-rw-r--r-- | behaviors/LocationMask.py | 19 | ||||
-rw-r--r-- | config/C5Sign.xml | 8 | ||||
-rw-r--r-- | pixelmappers/C5SignMapper.py | 11 |
3 files changed, 36 insertions, 2 deletions
diff --git a/behaviors/LocationMask.py b/behaviors/LocationMask.py new file mode 100644 index 0000000..51eafeb --- /dev/null +++ b/behaviors/LocationMask.py @@ -0,0 +1,19 @@ +from operationscore.Behavior import * + +class LocationMask (Behavior): + """Modifies Pixels such that only ones in the pixels specified by the "location" + argument will show""" + + def processResponse(self, inputs, state): + + ret = [] + inputs = list(inputs) + + for inputset in inputs: + inputset = dict(inputset) + + inputset['Location'] += '@' + self['Location'] + + ret.append(inputset) + + return (ret, []) diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 8039c07..6d7de20 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -124,6 +124,7 @@ <Id>colorchange</Id> <Id>mover</Id> <Id>slowdecay</Id> + <Id>wordsonly</Id> </ChainedBehaviors> <RecursiveHooks>{'mover':'bar_move'}</RecursiveHooks> <RenderToScreen>False</RenderToScreen> @@ -180,6 +181,13 @@ </Args> </Behavior> <Behavior> + <Class>behaviors.LocationMask</Class> + <Args> + <Id>wordsonly</Id> + <Location>wt.all cl.all c5.all</Location> + </Args> + </Behavior> + <Behavior> <Class>behaviors.BehaviorChain</Class> <Args> <Id>movebounce</Id> diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py index 24631c4..6d5163d 100644 --- a/pixelmappers/C5SignMapper.py +++ b/pixelmappers/C5SignMapper.py @@ -98,8 +98,15 @@ class C5SignMapper(PixelMapper): eventLocSplit = eventLocation.split('@') if len(eventLocSplit) == 2: [eventLocation, signPart] = eventLocSplit - signParts = signPart.split('.') - pixelLocs = signPosition[signParts[0]][signParts[1]] + signParts = signPart.split(' ') + #print "*******************" + #print signParts + pixelLocs = [] + for part in signParts: + if len(part) > 0: + parts = part.split('.') + pixelLocs.extend(self.signPosition[parts[0]][parts[1]]) + #print pixelLocs screenPixels = [p for p in screen if (p.location in pixelLocs)] else: screenPixels = [p for p in screen] |