4 ms·
The author mentioned YUV4MPEG. It's a wonderfully simple video format, here's a tiny C program to stream a video of Game of Life (With colours!): #define
by Retr0spectrum 9y ago
The author mentioned YUV4MPEG. It's a wonderfully simple video format, here's a tiny C program to stream a video of Game of Life (With colours!):
#define F for(i=0;i<l*3;i++)
main(n){int i,j,w=640,h=480,l
=w*h,o[]={~w,-w,-w+1,-1,1,w-1
,w,w+1},b[l*5];F b[i]=rand();
for(puts("YUV4MPEG2 W640 H48"
"0 F30 C444");puts("FRAME");)
{F{for(n=j=8;j;n-=b[i+o[--j]]
&1);b[i+l]=(n^5&&!b[i]|n^6)-1
;}F putchar(b[i]=b[i+l]);}}
(You can pipe the output to mpv or a similar media player.)
- sillysaurus3 9y agoHeh. I tried running that code through three different beautifiers and they all failed spectacularly. For those of us who don't enjoy visual self-flagellation, here's an attempt at untying the above ball of yarn: #define F for(i=0;i<l3;i++) main(n) { int i,j, w=640, h=480, l=w*h, o[] = { ~w, -w, -w+1, -1, 1, w-1, w, w+1 }, b[l*5]; F b[i]=rand(); for( puts("YUV4MPEG2 W640 H48" "0 F30 C444"); puts("FRAME"); ) { F { for( n=j=8; j; n-=b[ i + o[--j] ]&1 ); b[i+l] = (n^5 && !b[i] | n^6) - 1; } F putchar( b[i]=b[i+l] ); } } EDIT: I had no idea you could italicize code blocks! This was an accident, but I'm going to leave it because it looks pretty. Has this always been a feature? I've never seen italicized monospace before. That first line is supposed to read "for(i=0; i < l times three ..." but the asterisk is somehow causing HN to italicize the code block. There's no matching closing asterisk, so this is pretty amusing.
- sillysaurus3 9y agofoo*bar baz See? No italicization. Now I'm curious what triggers it...
- sillysaurus3 9y agofoobar baz*quux Aha. HN's parser is matching with the asterisk in the code snippet.
- dingo_bat 9y agoIt even affects the reply button/text.
- coldtea 9y agoA dangling asterisk -- which turns on italics mode on HN -- without the matching asterisk to end it.
- Retr0spectrum 9y agoI think you can fix it by putting the first line with the #define in the code block too.
- qb45 9y ago> Has this always been a feature? I've seen it before so I think it's always been a bug :)