From 1679719e7ca8ce433c5714474a32c926161dc5b8 Mon Sep 17 00:00:00 2001 From: rcoh Date: Tue, 4 Jan 2011 17:23:30 -0500 Subject: Some performance improvements -- we also synchronize all the frames, giving us a meaning that even if things slow down, rendering doesn't look weird. --- pixelmappers/GaussianMapper.py | 10 +++++----- pixelmappers/SimpleMapper.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'pixelmappers') diff --git a/pixelmappers/GaussianMapper.py b/pixelmappers/GaussianMapper.py index 8fdf16b..686ebcd 100644 --- a/pixelmappers/GaussianMapper.py +++ b/pixelmappers/GaussianMapper.py @@ -4,11 +4,11 @@ class GaussianMapper(PixelMapper): def mappingFunction(self, eventLocation, screen): returnPixels = [] #TODO: consider preallocation and trimming [x,y] = eventLocation - for (x,pixel) in screen.pixelsInRange(x-self['CutoffDist'], \ - x+self['CutoffDist']): + for (x,pixel) in screen.pixelsInRange(x-self.CutoffDist, \ + x+self.CutoffDist): pixelDist = Geo.dist(pixel.location, eventLocation) - if pixelDist < self['CutoffDist']: - w = Geo.gaussian(pixelDist, self['Height'], 0, self['Width']) - if w > self['MinWeight']: + if pixelDist < self.CutoffDist: + w = Geo.gaussian(pixelDist, self.Height, 0, self.Width) + if w > self.MinWeight: returnPixels.append((pixel, w)) return returnPixels diff --git a/pixelmappers/SimpleMapper.py b/pixelmappers/SimpleMapper.py index 5df1032..4d12fe4 100644 --- a/pixelmappers/SimpleMapper.py +++ b/pixelmappers/SimpleMapper.py @@ -22,7 +22,8 @@ class SimpleMapper(PixelMapper): eventLocation = eventLocation.replace('{y}', 'pixel.location[1]') for pixel in screen: try: - pixelValid = sum(eval(eventLocation)) == len(eval(eventLocation)) #TODO: some + preValid = eval(eventLocation) + pixelValid = sum(preValid) == len(preValid) #TODO: some #optimizations possible. This might be slow in the long run if pixelValid: ret.append((pixel, 1)) -- cgit v1.2.3