I took a stab at reinventing the wheel a day or two ago. Using Python 3 and a version of curses for Windows, I made a crude little "video player", which is really more like an animation player.
Code:
This is the player after I "golfed" it. It takes video data that is R rows and C columns from F, and outputs it to the terminal. The data is interpreted like this:
Before drawing the frame, the cursor is set to the top left corner, and the drawing direction is horizontal.
If it finds a hex digit from 0 to f, a pixel is drawn at the current cursor position that is that color, and the cursor is advanced.
If it finds <, >, ^, or V, the cursor is moved in that direction, with wrapping. Wrapping down or right cause the column or row to increment, and wrapping up or left causes the column or row to decrement.
If it finds - or |, the drawing direction is changed to horizontal or vertical, respectively.
If it finds *xxy, y is done xx times. Only raw data and cursor movement can be repeated.
If it finds =xxyy, the cursor position is set to row xx and column yy.
If it finds #, the current frame is displayed to the screen, and the cursor and drawing direction are reset.
The video I have loaded now is a "Hello World" demo (a globe that says "HELLO"). One can change the R, C, and F values to whatever they want for their own custom video. Please let me know if you figure that much out.
Test this out on your own system! If it doesn't work, let me know.
Code:
from curses import *
import time
R=15;C=15;F=('*05f*051*08f11*05b11*05f1*09b1fff1*11b1ff1*11b1f'+'1*13b1'*5+'f1*11b1ff1*11b1fff1*09b1*05f11*05b11*08f*051*05f#|*88>*052#|*87>*052*74<bb2bb#|*86>*052*74<bb2bb*74<*052#|*85>*052*74<bb2bb*74<*052*74<*05b#|*84>*052*74<bb2bb*74<*052*74<*05b*74<*052#|*83>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2#|*82>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b#|*81>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b#|*80>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052#|*79>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb#|*78>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb#|*77>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb>>b#|*76>*052*74<bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb>>b*74<*052#|*76>bb2bb*74<*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb#|*76>*052*74<*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb#|*76>*05b*74<*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb>>b#|*76>*052*59<b2b2*44<b*44<*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb>>b*74<*052#|*91>b2b2*44<b*44<*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb>>b*74<*052*59<bbb#|=0701b*44<*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb>>b*74<*052*59<bbb*44<222#|*76>*05b*74<*052*74<bbbb>>b*74<*052*74<bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*76>*052*74<bbbb>>b*74<*052*74<bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*76>bbbb>>b*74<*052*74<bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*88<b*74<*052*74<bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*89<b*74<*052*74<bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*76>*052*74<bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*76>bbbb>>b*74<*052*59<bbb*44<222*59<*05b#|*88<b*74<*052*59<bbb*44<222*59<*05b#|*89<b*74<*052*59<bbb*44<222*59<*05b#|*76>*052*59<bbb*44<222*59<*05b#|*91>bbb*44<222*59<*05b#|*91>222*59<*05b').split('#')
def m(s):
def x():
nonlocal r,c
if (r!=r%R)+(c!=c%C):j=(r+1-(c<0)*2)*(c!=c%C)-(r<0);c=((c+1-(r<0)*2)*(r!=r%R)-(c<0))%C;r=j%R
def d(l):nonlocal r,c,H;s.addstr(r+2,c*2+2,' ',color_pair('0123456789abcdef'.find(l)));r+=H;c+=1-H
resizeterm(R+3,C*2+4);curs_set(0);s.addstr('Hello, World!')
for i in range(1,16):init_pair(i,0,i)
s.nodelay(1);w=1
while w:
for f in F:
c=r=H=P=0
while P<len(f):
b=f[P]
if b=='=':r=int(f[P+1:P+3]);c=int(f[P+3:P+5]);P+=4
elif b=='*':
P+=3;p=f[P]
for i in range(int(f[P-2:P])):
if p in '< >':c+='< >'.find(p)-1
elif p in '^ V':r+='^ V'.find(p)-1
else:d(p)
x()
elif b in '< >':c+='< >'.find(b)-1
elif b in '^ V':r+='^ V'.find(b)-1
elif b in '-|':H=b=='|'
else:d(b)
P+=1;x()
s.refresh();time.sleep(1/24.0)
if s.getch()>=0:w=0;break
s=initscr();wrapper(m)
This is the player after I "golfed" it. It takes video data that is R rows and C columns from F, and outputs it to the terminal. The data is interpreted like this:
Before drawing the frame, the cursor is set to the top left corner, and the drawing direction is horizontal.
If it finds a hex digit from 0 to f, a pixel is drawn at the current cursor position that is that color, and the cursor is advanced.
If it finds <, >, ^, or V, the cursor is moved in that direction, with wrapping. Wrapping down or right cause the column or row to increment, and wrapping up or left causes the column or row to decrement.
If it finds - or |, the drawing direction is changed to horizontal or vertical, respectively.
If it finds *xxy, y is done xx times. Only raw data and cursor movement can be repeated.
If it finds =xxyy, the cursor position is set to row xx and column yy.
If it finds #, the current frame is displayed to the screen, and the cursor and drawing direction are reset.
The video I have loaded now is a "Hello World" demo (a globe that says "HELLO"). One can change the R, C, and F values to whatever they want for their own custom video. Please let me know if you figure that much out.
Test this out on your own system! If it doesn't work, let me know.