Anonymous avatar Anonymous committed 80cfe0b

started to add burroughs

Comments (0)

Files changed (2)

 """
 
 import markov
-print markov.__file__
+import burroughs
 
 class Lexer:
     def __init__(self, dev):
         self.words = []
         self.rows = []
         self.markov = None
+        self.burroughs = None
         self.algorithm = "straight"
         self.position = 0
         self.velocity = 1
             text = open(fakedrive).read()
             self.words = text.split()
             self.markov = markov.Markov(text)
+            self.burroughs = burroughs.Burroughs(text)
         else:
-        	pass
+            pass
             #mount the drive
             #glob text files and read the 1st one into buffer
             #unmount		
         out = ""
         if self.algorithm == "straight":
             out += self.words[self.position] + " "
-        if self.algorithm == "markov":
-        	out += self.markov.get_next(inword) + " "
+        elif self.algorithm == "markov":
+            out += self.markov.get_next(inword) + " "
+        elif self.algorithm == "burroughs":
+            out += self.burroughs.get_next()
         self.position += self.velocity 
         if self.position == len(self.words):
             self.position = 0
     
     def update_input(self, line):
         pass
-        
+        
 import lexer
-import random
+import random
 import math
 
 deck_A = lexer.Lexer("/dev/fd0")
-deck_B = lexer.Lexer("/dev/fd1")
+deck_B = lexer.Lexer("/dev/fd1")
 font = "fonts/pcsenior.ttf"
-out_text = [] # list of screen text rows
+out_text = [] # list of screen text rows
 cursor = ScreenText()
 ypos = 0
-wordrate = 3
-rows = 12
-font_size = 28
-ROW_WIDTH = 23
-reverse = False
-bgcolor = (0, 0, 0)
-
-#TODO: word clock and fixed frame rate
-#TODO: deck loading in separate thread
-#TODO: burroughs slicer
-#TODO: color knob
-#TODO: trog mode!!
-#TODO: console out
-#TODO: text-monitor switch
-#TODO: fx
-
-def handle_keydown(event):
-    print "got keydown: " + event.unicode
-    if event.unicode == "r":
-        global reverse
-        reverse = True
-    if event.unicode == "t":
-        global bgcolor
-        bgcolor = (255,255,255)
-        for row in rows:
-            row.setColor(0,0,0)
-    
-def handle_keyup(event):
-    print "got keyup: " + str(event.key)
-    if event.key == pygame.K_r:
-        global reverse
+wordrate = 3
+rows = 12
+font_size = 28
+ROW_WIDTH = 23
+reverse = False
+bgcolor = (0, 0, 0)
+
+#TODO: word clock and fixed frame rate
+#TODO: deck loading in separate thread
+#TODO: burroughs slicer
+#TODO: color knob
+#TODO: trog mode!!
+#TODO: console out
+#TODO: text-monitor switch
+#TODO: fx
+#TODO: set to 72 Characters per Line
+
+def handle_keydown(event):
+    print "got keydown: " + event.unicode
+    if event.unicode == "r":
+        global reverse
+        reverse = True
+    if event.unicode == "t":
+        global bgcolor
+        bgcolor = (255,255,255)
+        for row in rows:
+            row.setColor(0,0,0)
+    
+def handle_keyup(event):
+    print "got keyup: " + str(event.key)
+    if event.key == pygame.K_r:
+        global reverse
         reverse = False
-
 
-def setup():
-    pycessing.size(640, 480)
-    pycessing.framerate = wordrate
-    
-    cursor.setFontFromFile(font, font_size)
+
+def setup():
+    pycessing.size(640, 480)
+    pycessing.framerate = wordrate
+    
+    cursor.setFontFromFile(font, font_size)
     
     for i in range(rows):
-        row = ScreenText()
-        row.setFontFromFile(font, font_size)
-        row.text = ""
+        row = ScreenText()
+        row.setFontFromFile(font, font_size)
+        row.text = ""
         #row.text = str(i)*22
         out_text.append(row)
     deck_A.load(fakedrive="test-data/freud-dreams.txt")
-    deck_B.load(fakedrive="test-data/poe-perloined-letter.txt")
-    deck_A.algorithm = "markov"
-    deck_B.algorithm = "markov"
-    print "done loading"
-    
-    pycessing.onKeyDown = handle_keydown
+    deck_B.load(fakedrive="test-data/poe-perloined-letter.txt")
+    deck_A.algorithm = "markov"
+    deck_B.algorithm = "markov"
+    print "done loading"
+    
+    pycessing.onKeyDown = handle_keydown
     pycessing.onKeyUp = handle_keyup
 	
-def draw():
+def draw():
     setBackground(bgcolor)
     
     # update tempo 
     
     # update x-fader
     xfader = pycessing.getMouseX() / float(pycessing.getWidth())
-    print "xfader " + str(xfader)
-    
-    # select deck and get next word
-    if random.random() < xfader:
+    print "xfader " + str(xfader)
+    
+
+    # 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)
-    
-    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    
+        cursor.setColor(0,255,255)
+
+    #TODO: do burroughs here
+    
+    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
+        row.draw(10, ypos)
+        ypos += step
+    cursor.draw(out_text[-1].getWidth()+10, ypos-step)
+    
+    out_text[-1].text += cursor.text
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.