Created
August 16, 2026 15:03
-
-
Save DamianSuess/048d1268070174cb022256a21b4afc0e to your computer and use it in GitHub Desktop.
Console Flame Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # Sample console fame animation | |
| # Based on with fixes: https://gist.github.com/msimpson/1096950 | |
| import curses, random | |
| screen = curses.initscr() | |
| width = screen.getmaxyx()[1] | |
| height = screen.getmaxyx()[0] | |
| size = width*height | |
| char = [" ", ".", ":", "^", "*", "x", "s", "S", "#", "$"] | |
| b = [] | |
| try: | |
| curses.curs_set(0) | |
| except curses.error: | |
| pass # Terminals without cursor visibility control will bypass safely | |
| curses.start_color() | |
| curses.init_pair(1,0,0) | |
| curses.init_pair(2,1,0) | |
| curses.init_pair(3,3,0) | |
| curses.init_pair(4,4,0) | |
| screen.clear | |
| for i in range(size+width+1): b.append(0) | |
| while 1: | |
| for i in range(int(width/9)): | |
| b[int((random.random()*width)+width*(height-1))]=65 | |
| for i in range(size): | |
| b[i]=int((b[i]+b[i+1]+b[i+width]+b[i+width+1])/4) | |
| color=(4 if b[i]>15 else (3 if b[i]>9 else (2 if b[i]>4 else 1))) | |
| if(i<size-1): | |
| screen.addstr(int(i/width), | |
| i%width, | |
| char[(9 if b[i]>9 else b[i])], | |
| curses.color_pair(color) | curses.A_BOLD ) | |
| screen.refresh() | |
| screen.timeout(10) | |
| if (screen.getch()!=-1): | |
| break | |
| curses.endwin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment