rendered paste body#!/usr/bin/pythonimport curses, sys, random, time, os## TODO## initialise curses## make used chars less liekly in random pool## >> randchar class i think, then make it public## PUT THE BLOODY COLOURS BACK!## make damn sure that curser is offCHARLIST = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}']if len(sys.argv) > 1: maxChars = int(sys.argv[1])else: maxChars = 3class ScreenObj(object): def __init__(self): self.stdscr = curses.initscr() curses.start_color() if curses.can_change_color(): curses.init_color(1, 0, 200, 0) curses.init_color(2, 0, 400, 0) curses.init_color(3, 0, 600, 0) curses.init_color(4, 0, 800, 0) curses.init_color(5, 0, 999, 0) else: pass curses.init_pair(1, 1, curses.COLOR_BLACK) curses.init_pair(2, 2, curses.COLOR_BLACK) curses.init_pair(3, 3, curses.COLOR_BLACK) curses.init_pair(4, 4, curses.COLOR_BLACK) curses.init_pair(5, 5, curses.COLOR_BLACK) self.height, self.width = self.stdscr.getmaxyx() self.stdscr.refresh() def _destroy(self): curses.endwin()class scrollingLetter(object): def __init__(self, screen, x=False, y=False, trailLength=3): global CHARLIST self.train = [random.choice(CHARLIST)] self.trailLength = trailLength self.length = 0 self.modeLength = len(self.getModes()) self.screen = screen if x == False: self.x = random.randint(0,self.screen.width) else: self.x = x if y == False: self.y = highRandInt(self.screen.height-8) else: self.y = 0 self.bottom = self.screen.height def getModes(self): return [curses.color_pair(5),curses.color_pair(4),curses.color_pair(3),curses.color_pair(2),curses.color_pair(1) ] def _pump(self): modes = self.getModes() self.length += 1 if self.y + self.length + 1> self.screen.height: return self._die(0) self.train.append(random.choice(CHARLIST)) i = 0 while i < len(self.train) and self.y + self.length-i< self.screen.height and i < self.modeLength: if len(modes) > 1: try: self.screen.stdscr.addstr(self.y+self.length-i, self.x, self.train[-i], modes.pop(0)) except: pass else: self.screen.stdscr.addstr(self.y+self.length-i, self.x, self.train[-i], modes[-1]) i += 1 return True def _die(self, newPos): for i in range(0, len(self.getModes())): try: self.screen.stdscr.addstr(self.y+self.length-i, self.x, self.train[-i], self.getModes()[-1]) except: pass return newPosdef highRandInt(high): low = high/2 return random.randint(0, low) + random.randint(0, low)Term = ScreenObj()curses.curs_set(False)curses.noecho()iterations = 0scrollers = []for i in range (0,Term.width): scrollers.append(scrollingLetter(Term, x=i, y=0))while 1: if len(scrollers) == 0: break i = random.choice(scrollers) oops = i._pump() if oops != True: scrollers.append(scrollingLetter(Term, i.x, y=oops)) del scrollers[scrollers.index(i)] #time.sleep(0.0001) Term.stdscr.refresh()Term._destroy()curses.nocbreak() #didn't use itcurses.echo()