From cb69d2e1c7ced951cbf7a31ee286b0ed92cab8a8 Mon Sep 17 00:00:00 2001 From: rcoh Date: Fri, 18 Feb 2011 16:56:43 -0500 Subject: Adding Epydoc generated docs. --- ...SmootLight.pixelmappers.SimpleMapper-pysrc.html | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 html/SmootLight.pixelmappers.SimpleMapper-pysrc.html (limited to 'html/SmootLight.pixelmappers.SimpleMapper-pysrc.html') diff --git a/html/SmootLight.pixelmappers.SimpleMapper-pysrc.html b/html/SmootLight.pixelmappers.SimpleMapper-pysrc.html new file mode 100644 index 0000000..b2a183f --- /dev/null +++ b/html/SmootLight.pixelmappers.SimpleMapper-pysrc.html @@ -0,0 +1,162 @@ + + + + + SmootLight.pixelmappers.SimpleMapper + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Package SmootLight :: + Package pixelmappers :: + Module SimpleMapper + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module SmootLight.pixelmappers.SimpleMapper

+
+ 1  from operationscore.PixelMapper import * 
+ 2  import util.Geo as Geo 
+ 3  import math 
+ 4  import sys 
+
5 -class SimpleMapper(PixelMapper): +
6 """SimpleMapper is a PixelMapper which maps events to the nearest Pixel. It also supports + 7 strings of the form: + 8 {x}>5, {y}<10, {x}*{y}<{x}, etc. (Conditions, separated by commas. Standard python syntax such + 9 as and and or may also be +10 used). You may use 'math.' functions such as math.sqrt, etc. It also accepts lists of strings""" +
11 - def mappingFunction(self, eventLocation, screen): +
12 if type(eventLocation) == type(tuple()): +13 bestDist = sys.maxint +14 bestPixel = None +15 [x,y] = eventLocation +16 for (x,pixel) in screen.pixelsInRange(x-self['CutoffDist'], \ +17 x+self['CutoffDist']): +18 pixelDist = Geo.dist(pixel.location, eventLocation) +19 if pixelDist < bestDist: +20 bestPixel = pixel +21 bestDist = pixelDist +22 if bestPixel != None: +23 return [(bestPixel,1)] +24 else: +25 return [] +26 else: +27 #{x}>5,{y}<k +28 ret = [] +29 if not isinstance(eventLocation, list): +30 eventLocation = eventLocation.replace('{x}', 'pixel.location[0]') +31 eventLocation = eventLocation.replace('{y}', 'pixel.location[1]') +32 conditions = eventLocation.split(',') +33 else: +34 conditions = eventLocation #TODO: check for lists of strings +35 conditionLambdas = [eval('lambda pixel:'+condition) for condition in conditions] +36 +37 for pixel in screen: +38 try: +39 pixelValid = True +40 for p in conditionLambdas: +41 if p(pixel) == False: +42 pixelValid = False +43 continue +44 if pixelValid: +45 ret.append((pixel, 1)) +46 except Exception as exp: +47 exp.message += 'Bad Event Condition' +48 raise exp +49 return ret +
50 +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + -- cgit v1.2.3