diff options
author | Russell Cohen <rcoh@mit.edu> | 2011-01-26 22:24:55 -0500 |
---|---|---|
committer | Russell Cohen <rcoh@mit.edu> | 2011-01-26 22:24:55 -0500 |
commit | 5d29906fff79bc6e4ba83be7028e1380a0014d21 (patch) | |
tree | 0bb2350046aa69c3b1095983fea59c49026a857b /pixelcore/Screen.py | |
parent | 2019fb2895237aa9d86450daaf6d90831189fc13 (diff) | |
parent | 82f99fc4583ca3cc9861a9fe30990a4a9ef162c4 (diff) |
Merge branch 'mobileapp' into biginstall
Conflicts:
behaviors/RestrictLocation.py
behaviors/Square.py
config/6thFloor.xml
inputs/TCPInput.py
layouts/60StripLayout.xml
operationscore/Behavior.py
operationscore/PixelMapper.py
pixelcore/Pixel.py
pixelcore/Screen.py
renderers/60StripSeq.xml
Diffstat (limited to 'pixelcore/Screen.py')
-rw-r--r-- | pixelcore/Screen.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py index a6fc8c4..b595847 100644 --- a/pixelcore/Screen.py +++ b/pixelcore/Screen.py @@ -19,25 +19,28 @@ class Screen: self.xSortedPixels = [] self.xPixelLocs = [] sizeValid = False - + self.pixelsSorted = False def addStrip(self, lS): self.pixelStrips.append(lS) self.sizeValid = False #keep track of whether or not our screen size has + self.pixelsSorted = False #been invalidated by adding more pixels - self.computeXSortedPixels() #Returns (pixelIndex, pixel). Does a binary search. def pixelsInRange(self, minX, maxX): + if not self.pixelsSorted: + self.computeXSortedPixels() minIndex = Search.find_ge(self.xPixelLocs, minX) maxIndex = Search.find_le(self.xPixelLocs, maxX)+1 return self.xSortedPixels[minIndex:maxIndex] def computeXSortedPixels(self): + self.xSortedPixels = [] for pixel in self: self.xSortedPixels.append((pixel.location[0], pixel)) self.xSortedPixels.sort() self.xPixelLocs = [p[0] for p in self.xSortedPixels] - + self.pixelsSorted = True #For debug only def allOn(self): [lS.allOn(-1) for lS in self.pixelStrips] @@ -77,6 +80,7 @@ class Screen: maxY = max(y, maxY) self.size = (0,0, maxX, maxY) self.sizeValid = True + print self.size return (0, 0, maxX+100, maxY+100) #TODO: cleaner #private |