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. --- html/SmootLight.pixelcore.Pixel-pysrc.html | 282 +++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 html/SmootLight.pixelcore.Pixel-pysrc.html (limited to 'html/SmootLight.pixelcore.Pixel-pysrc.html') diff --git a/html/SmootLight.pixelcore.Pixel-pysrc.html b/html/SmootLight.pixelcore.Pixel-pysrc.html new file mode 100644 index 0000000..94c355e --- /dev/null +++ b/html/SmootLight.pixelcore.Pixel-pysrc.html @@ -0,0 +1,282 @@ + + + + + SmootLight.pixelcore.Pixel + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Package SmootLight :: + Package pixelcore :: + Module Pixel + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module SmootLight.pixelcore.Pixel

+
+ 1  import util.ColorOps as color 
+ 2  from logger import main_log 
+ 3  import pdb 
+ 4  from pixelevents.StepEvent import * 
+ 5  import util.TimeOps as timeops 
+
6 -class Pixel: +
7 """Pixel keeps a queue of events (PixelEvent objects) (actually a dictionary + 8 keyed by event time). Every time is state is + 9 requested, it processes all the members of its queue. If a member returns none, +10 it is removed from the queue. Otherwise, its value added to the Pixels color +11 weighted by z-index. To get the current color of the pixel, call the state method.""" +12 +13 radius = 2 +14 timeOff = -1 +15 +
16 - def __init__(self, location): +
17 self.location = location +18 self.events = [] +19 self.lastRenderTime = timeops.time() +20 self.lastRender = (0,0,0) +
21 +
22 - def turnOn(self): +
23 self.turnOnFor(-1) +
24 +25 #Turn the light white for 'time' ms. Really only meant for testing. Use +26 #processInput instead. Also, you shouldn't use this anyway. You should be +27 #using the input method on the screen! +
28 - def turnOnFor(self, time): +
29 event = StepEvent.generate(time, (255,255,255)) +30 self.processInput(event, 0) +
31 +32 #Add a pixelEvent to the list of active events +
33 - def processInput(self,pixelEvent,zindex, scale=1,currentTime=None): #consider migrating arg to dict +
34 if currentTime == None: +35 currentTime = timeops.time() +36 self.events.append((currentTime, zindex, scale, pixelEvent)) #TODO: clean this up, maybe? +
37 - def clearAllEvents(self): +
38 self.events = [] +
39 +
40 - def state(self, currentTime=None): +
41 """Combines all PixelEvents currently active and computes the current color of +42 the pixel.""" +43 if currentTime == None: +44 currentTime = timeops.time() +45 if currentTime-self.lastRenderTime < 5: +46 return self.lastRender +47 if self.events == []: +48 self.lastRenderTime = currentTime +49 return (0,0,0) +50 deadEvents = [] +51 resultingColor = (0,0,0) +52 colors = [] +53 for eventObj in self.events: #TODO: right color weighting code +54 if len(self.events) > 50: +55 main_log.error('High pixel event count! Investigate!') +56 eventTime, zindex, scale, pixelEvent = eventObj +57 eventResult = pixelEvent.state(currentTime-eventTime) +58 if eventResult != None: +59 scaledEvent = color.multiplyColor(eventResult,scale) +60 if (scaledEvent[0] + scaledEvent[1] + scaledEvent[2]) < 5: +61 pass +62 #deadEvents.append(eventObj) +63 else: +64 colors.append(scaledEvent) +65 else: +66 deadEvents.append(eventObj) +67 +68 resultingColor = color.combineColors(colors) +69 [self.events.remove(event) for event in deadEvents] +70 resultingColor = [int(round(c)) for c in resultingColor] +71 self.lastRender = tuple(resultingColor) +72 self.lastRenderTime = currentTime +73 return tuple(resultingColor) +74 +
75 - def __str__(self): +
76 return 'Loc: ' + str(self.location) +
77 +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + -- cgit v1.2.3