From 43bf9e8b188638ca2e11f5dff691cf54902ac8dc Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 16:34:40 -0500 Subject: Completed C5SignMapper, first version --- pixelmappers/C5SignMapper.py | 95 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 16 deletions(-) diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py index b310c59..79ebe1a 100644 --- a/pixelmappers/C5SignMapper.py +++ b/pixelmappers/C5SignMapper.py @@ -9,16 +9,73 @@ class C5SignMapper(PixelMapper): (Conditons, separated by commas. and and or may also be used).""" signPosition = { - "ls" : [(2,8), (2,14), (2,20)], - "ts" : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22), - (44, 22)], - "rs" : [(45,2), (45, 8), (45,14), (45,20)], - "bs" : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)], - "wt" : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5), - (30,5), (34,5), (37,5)], - "cl" : [(17,8), (21,10), (24,10), (26,12), (31,12)], - "c5" : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16), - (34, 16), (38,17), (42,17)]} + "ls" : { + 'all' : [(2,2),(2,8), (2,14), (2,20)], + '1' : [(2,2)], + '2' : [(2,8)], + '3' : [(2,14)], + '4' : [(2,20)] }, + "ts" : { + 'all' : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22), (44, 22)], + '1' : [(4,22)], + '2' : [(10,22)], + '3' : [(16,22)], + '4' : [(22,22)], + '5' : [(27,22)], + '6' : [(33,22)], + '7' : [(39,22)], + '8' : [(44,22)] }, + "rs" : { + 'all' : [(45,2), (45, 8), (45,14), (45,20)], + '1' : [(45,2)], + '2' : [(45,8)], + '3' : [(45,14)], + '4' : [(45,20)] }, + "bs" : { + 'all' : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)], + '1' : [(4,2)], + '2' : [(10,2)], + '3' : [(16,2)], + '4' : [(22,2)], + '5' : [(27,2)], + '6' : [(33,2)], + '7' : [(39,2)], + '8' : [(44,2)] }, + "wt" : { + 'all' : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5), (30,5), (34,5), (37,5)], + '1' : [(12,5), (13,5)], + '2' : [(16,5)], + '3' : [(18,5)], + '4' : [(21,5)], + '5' : [(23,5)], + '6' : [(26,5),(27,5)], + '7' : [(30,5)], + '8' : [(34,5)], + '9' : [(37,5)] }, + "cl" : { + 'all' : [(17,8), (21,10), (24,10), (26,12), (31,12)], + 'in' : [(21,10),(24,10),(26,12)], + 'out' : [(17,8),(31,12)], + '1' : [(17,8)], + '2' : [(21,10)], + '3' : [(24,10)], + '4' : [(26,12)], + '5' : [(31,12)] }, + "c5" : { + 'all' : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16), (34, 16), (38,17), (42,17)], + 'con' : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17)], + 'five': [(33,16), (34, 16), (38,17), (42,17)], + '1' : [(6,17)], + '2' : [(11,17)], + '3' : [(15,17)], + '4' : [(19,17)], + '5' : [(22,17)], + '6' : [(27,17)], + '7' : [(33,16)], + '8' : [(34,16)], + '9' : [(38,17)], + '10' : [(42,17)] }, + } def mappingFunction(self, eventLocation, screen): if type(eventLocation) == type(tuple()): @@ -35,19 +92,25 @@ class C5SignMapper(PixelMapper): return [(bestPixel,1)] else: return [] - elif type(eventLocation) == type else: - eventLocSplit = eventLocation.split(' :: ') + #pixel locs + eventLocSplit = eventLocation.split('@') if len(eventLocSplit) == 2: - [signPart, eventLocation] = eventLocSplit - signParts = [signPosition[x] for x in signPart.split(' ')] + [eventLocation, signPart] = eventLocSplit + signParts = signPart.split('.') + pixelLocs = signPosition[signParts[0]][signParts[1]] + screen = [p for p in screen if (p.location in pixelLocs)] + #{x}>5,{y} 0: + conditions = eventLocation.split(',') + conditionLambdas = [eval('lambda pixel:'+condition) for condition in conditions] + else: + conditionLambdas = [] for pixel in screen: try: pixelValid = True -- cgit v1.2.3 From 7a4f06d15b0fe9bd22996af6a1ca2c3ca5ca3e3f Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 13 Feb 2011 19:00:44 -0500 Subject: Added a vertical bars animation to C5Sign-dxiao --- behaviors/VerticalBar.py | 30 +++ config/C5Sign-dxiao.xml | 396 ++++++++++++++++++++++++++++++++++++++ config/C5Sign.xml | 2 +- inputs/ContinuousLocationInput.py | 19 ++ pixelmappers/C5SignMapper.py | 8 +- 5 files changed, 452 insertions(+), 3 deletions(-) create mode 100644 behaviors/VerticalBar.py create mode 100644 config/C5Sign-dxiao.xml create mode 100644 inputs/ContinuousLocationInput.py diff --git a/behaviors/VerticalBar.py b/behaviors/VerticalBar.py new file mode 100644 index 0000000..e1a67fe --- /dev/null +++ b/behaviors/VerticalBar.py @@ -0,0 +1,30 @@ +from operationscore.Behavior import * +class VerticalBar(Behavior): + + def processResponse(self, inputs, recurs): + + ret = [] + for inputset in inputs: + #import pdb; pdb.set_trace() + + if 'xLoc' not in inputset: + inputset['xLoc'] = inputset['Location'][0] + xLoc = inputset['xLoc'] + + condition = '{x} == ' + str(xLoc) + + if self['Combine']: + inputset['Location'] += ',' + condition + else: + inputset['Location'] = condition + + ret.append(inputset) + + return (ret, []) + + def setLastOutput(self, output): + + coutput = Behavior.deepCopyPacket(output) + for data in coutput: + data['Location'] = data['xLoc'] + return coutput diff --git a/config/C5Sign-dxiao.xml b/config/C5Sign-dxiao.xml new file mode 100644 index 0000000..38eb40c --- /dev/null +++ b/config/C5Sign-dxiao.xml @@ -0,0 +1,396 @@ + + + + + simplemap + + + + layouts/C5SignLayout.xml + + + + + pixelmappers.C5SignMapper + + c5signmapper + 20 + + + + + pixelmappers.SimpleMapper + + simplemap + 20 + + + + pixelmappers.GaussianMapper + + gaussmap + 30 + 0.1 + 7 + 1 + + + + + + renderers/C5Renderer.xml + + + renderers/Pygame.xml + + + + + + inputs.OSCInput + + osc + 1234 + 10 + + + + + inputs.UDPInput + + udp + 3344 + 50 + + + + inputs.ContinuousCenterInput + + center + 1800 + + + + + inputs.ContinuousLocationInput + + centerleft + left + center + 1800 + + + + + + + + + + touchosc + + behaviors.TouchOSC + + + behaviors/RandomColor.xml + + + + + + behaviors.BehaviorChain + + OSCTouchChase + + osc + + + touchosc + decay + + gaussmap + False + + + + behaviors/PixelDecay.xml + + + behaviors/SingleFrame.xml + + + + behaviors/PixelDecay.xml + + .001 + + + + + behaviors.XYMove + + xymove + 1 + 1 + + + + behaviors.RestrictLocation + + xbounce + {val}*-1 + XStep + {x}<2 or {x}>48 + + + + behaviors.RestrictLocation + + ybounce + {val}*-1 + YStep + {y}<2 or {y}>24 + + + + behaviors.BehaviorChain + + movebounce + + xymove + ybounce + xbounce + + + + + behaviors.ModifyParam + + ysin + YStep + Sensor + 4*math.sin({x}/float(40)) + + + + behaviors.DebugBehavior + + debug + 0 + + pygamekey + udp + + + + + behaviors.AllPixels + + square + 20 + + + + behaviors/LoopAndDie.xml + + 160 + + + + behaviors.BehaviorChain + + runcolordecay + + pygameclick + + + colorchange + mover + + decay + + {'mover':'movebounce'} + False + gaussmap + + + + behaviors.ResponseMover + + mover + + + + behaviors.RandomWalk + + randmovement + 2 + + + + behaviors/Accelerate.xml + + + behaviors.EchoBehavior + + echo + 0 + False + + + + behaviors.ColorShift + + colorshift + + + + behaviors.BehaviorChain + + mousechaser + + + + echo + innercircle + outercircle + singleframe + + False + + + + behaviors.Circle + + innercircle + 0 + True + + + + behaviors.Circle + + outercircle + 3 + True + + + + behaviors.ModifyParam + + incrinner + {val}+.3 + innercircleRadius + + + + behaviors.ModifyParam + + incrouter + {val}+.3 + outercircleRadius + + + + behaviors.BehaviorChain + + circle_expand + + innercircle + outercircle + incrinner + incrouter + recursivedecay + + + + + behaviors.BehaviorChain + + expandingcirlces + + centerleft + + + colorchange + mover + decay + + {'mover':'circle_expand'} + False + + + + + behaviors.ModifyParam + + incrVertBarLoc + xLoc + {val}+1 + + + + behaviors.VerticalBar + + vertBar + + + + behaviors.BehaviorChain + + bar_move + + vertBar + incrVertBarLoc + recursivedecay + + + + + behaviors.BehaviorChain + + scanningbars + + centerleft + + + colorchange + mover + slowdecay + + {'mover':'bar_move'} + True + + + + + behaviors/RunningBehavior.xml + + + diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 02bd0a2..45e42de 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -10,7 +10,7 @@ - pixelmappers.SimpleMapper + pixelmappers.C5SignMapper simplemap 20 diff --git a/inputs/ContinuousLocationInput.py b/inputs/ContinuousLocationInput.py new file mode 100644 index 0000000..f39bd9b --- /dev/null +++ b/inputs/ContinuousLocationInput.py @@ -0,0 +1,19 @@ +import util.TimeOps as clock +import util.ComponentRegistry as compReg +import util.Strings as Strings +from operationscore.Input import * +class ContinuousLocationInput(Input): + '''Continuously returns one of nine positions on the screen as specified by the xloc + and yloc arguments, which can take values 'min', 'max', and 'center'. ''' + def inputInit(self): + xvals = {} + yvals = {} + xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize() + (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2) + + self.location = (xvals[self['xloc']], yvals[self['yloc']]) + + def sensingLoop(self): + print (self.location) + self.respond({Strings.LOCATION: self.location}) + diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py index 79ebe1a..24631c4 100644 --- a/pixelmappers/C5SignMapper.py +++ b/pixelmappers/C5SignMapper.py @@ -1,6 +1,7 @@ from operationscore.PixelMapper import * import util.Geo as Geo import sys +import math class C5SignMapper(PixelMapper): """C5SignMapper is a modification to SimpleMapper which maps events to the nearest Pixel. In addtion, it also maps sign artifacts (letters, logo, etc) @@ -99,7 +100,9 @@ class C5SignMapper(PixelMapper): [eventLocation, signPart] = eventLocSplit signParts = signPart.split('.') pixelLocs = signPosition[signParts[0]][signParts[1]] - screen = [p for p in screen if (p.location in pixelLocs)] + screenPixels = [p for p in screen if (p.location in pixelLocs)] + else: + screenPixels = [p for p in screen] #{x}>5,{y}