Commits

Brendan  committed c7af9af

separate wordclock

  • Participants
  • Parent commits 5b1e908

Comments (0)

Files changed (2)

     	try:
     		inword = inword.strip()
     		out = random.choice(self.dict[inword])
-    		print "hit"
+    		#print "hit"
     	except:
     		out = random.choice(self.words)
-    		print "cache miss"
+    		#print "cache miss"
     	return out        
          
 ypos = 0
 framerate = 25
 wordrate = 3
+wordcounter = 0
 rows = 12
 font_size = 14
 ROW_WIDTH = 45
 	
 def draw():
     
-    
+    skip_frame = True
     # update tempo 
     # TODO: optimize exponential ops, only trigger on event
-    wordrate = 60 * ((pycessing.getMouseY() / float(pycessing.getHeight())) ** 3)
+    wordrate = 0.5 / ( (pycessing.getMouseY()+1) / float( pycessing.getHeight() ))
     #pycessing.framerate = wordrate + 0.25
     print "wordrate " + str(wordrate +0.25)
     
     setBackground(bgcolor[0], bgcolor[1], bgcolor[2])
     # update x-fader
     xfader = pycessing.getMouseX() / float(pycessing.getWidth())
-    print "xfader " + str(xfader)
+    #print "xfader " + str(xfader)
+    
+    global wordcounter 
+    print wordcounter
+    wordcounter += 1
+    if wordcounter > wordrate:
+        wordcounter = 0
+        skip_frame = False
     
+        # select deck and get next word  (TODO:skip for burroughs)
+        if random.random() < xfader:
+            cursor.text = deck_A.get_word(cursor.text)
+            cursor.setColor(255,255,0)
+        else:
+            cursor.text = deck_B.get_word(cursor.text)
+            cursor.setColor(0,255,255)
 
-    # select deck and get next word  (TODO:skip for burroughs)
-    if random.random() < xfader:
-        cursor.text = deck_A.get_word(cursor.text)
-        cursor.setColor(255,255,0)
-    else:
-        cursor.text = deck_B.get_word(cursor.text)
-        cursor.setColor(0,255,255)
+        #TODO: do burroughs here
+        
 
-    #TODO: do burroughs here
-    
+            
+        #if cursor row full - line feed
+        if (len(out_text[-1].text) + len(cursor.text)) > ROW_WIDTH:
+            idx = 0
+            for row in out_text[:-1]:
+                row.text = out_text[idx+1].text
+                idx += 1
+            out_text[-1].text = ""
+            
     if reverse:
         ypos = 446
         step = -38
     else:
         ypos = 10
         step = 38
-        
-    #if cursor row full - line feed
-    if (len(out_text[-1].text) + len(cursor.text)) > ROW_WIDTH:
-        idx = 0
-        for row in out_text[:-1]:
-            row.text = out_text[idx+1].text
-            idx += 1
-        out_text[-1].text = ""
     
     # update screen    
     for row in out_text:
         row.draw(10, ypos)
         ypos += step
-    cursor.draw(out_text[-1].getWidth()+10, ypos-step)
-    
-    out_text[-1].text += cursor.text
+     
+    if not(skip_frame):
+        cursor.draw(out_text[-1].getWidth()+10, ypos-step)
+        out_text[-1].text += cursor.text