Yahoo Logo ASCII Animation in 462 bytes of C (2011)
a1k0n.net
a1k0n.net
http://iquilezles.org/www/articles/distfunctions/distfunctio...
http://iquilezles.org/www/articles/raymarchingdf/raymarching...
Edit: The description for the "bridge" scene is interesting: "This is a sketch really, but it never got completed, due to the lack of artistic appealing of the image." I don't know if it's his extreme humility, but I think it wouldn't be overexaggerating if I said it's one of the best scenes on that page.
dist(p, t) = (1-t)*dist0(p) + t*dist1(p)
T doesn't have to be time-based, it can be space-based, so you have a shape that's a cylinder on the bottom and a large sphere on top and here's a mushroom https://www.shadertoy.com/view/lsSXWcEdit: I have a very strong feeling that in most cases the resulting function isn't a "proper" distance field, but you can still raymarch through it normally.
Here are some complete APL programs[2] to give a flavor of just how dense it can get:
Sum integers from 1 to 100:
+/ι100
Find all primes from 2 to a given number R: (∼R∈R◦.×R)/R←1↓ιR
Play Conway's Game of Life: life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}
[1] https://en.wikipedia.org/wiki/APL_%28programming_language%29 #include <math.h> /* outputs 8 kHz 8-bit unsigned pcm to stdout */
main(v,i,z,n,u,t){for(v=-1;;)for(n=pow(/* gcc -lm sig.c;./a.out>/dev/dsp */
1.06,"`cW`g[`cgcg[eYcb^bV^eW^be^bVecb^"[++v&31]+(v&64)/21),i=999;i;putchar(
128+((8191&u)>i?0:i/8)-((8191&(z+=n))*i-->>16)))u+=v&1?t/2: (t=v&6?t:n/4);}
edit: fixed copy/paste error $ gcc -lm sig.c
sig.c: In function ‘main’:
sig.c:3: error: expected ‘;’ before numeric constant
Fixed this statement:< i=9 99;
> i=999;
Garbage is displayed when I execute the code.
https://jsbin.com/tazeyoqoci/edit?html,output
Amazing work.
You can do something similar using Chrome's console output. There used to be an intro that worked by rendering a canvas as ascii but it's broken in newer Chrome - http://sandbox.photonstorm.com/console.log/ (it may work for other people). I figured out how it works and made a little animation to explore the principle - http://ooer.com/console/i.html (You'll need to change the height of the console to fit 16 lines of output)
Then you look at it and realize that a "line" is actually 20 different statements minified.
I found jquery implemented in a single line![1]
> Yahoo Logo ASCII Animation in one line of C (2011)
What's the difference between six lines of C and one line of C?
for(i=0;i<4;i++)
This is three lines?The problem with using those for code metrics is that many systems don't require separators, like `if`, `for` and friends
Nonetheless, these things are fun and often novel, both in what they accomplish and how they accomplish it. I like looking at them (not always reading them) for many of the same reasons I like looking at brainfuck or perl code. Plus, you know, compression. ;)
At least one of the computer magazines of the day had a regular column of one-line BBC Basic programs sent in by readers. There were some quite good games.
Alas, I suspect that most of these have been lost to history, but here's a one-line Tetris:
0d=d:IFdVDUd:a=POINT(32*POS,31-VPOS<<5):RETURNELSEMODE9:GCOL-9:CLG:O
FF:d=9:REPEATVDU30:REPEATGOSUBFALSE:IFPOS=28VDUPOS,15,VPOS,24;11,26:IF0E
LSEIFa=0PRINT:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:i=0:VDU4895;3:REPEATm=
9-INKEY6MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOURv-15:VDUrEORm:i+=m=7AND9
-6*r:IF0ELSEFORn=0TO11:d=n/3OR2EORd:GOSUBFALSE:IF1<<(n+i)MOD12AND975AND&
C2590EC/8^vVDU2080*ABSr;:t+=a:IF0ELSENEXT,:VDU20:UNTILt*LOGm:UNTILVPOS=3
http://survex.com/~olly/rheolism/dsm_rheolism/