Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Barnsley's Fern

Name: Anonymous 2009-06-13 17:31

Minimal Barnsley's Fern (lolwikipedia) in html and javascript:

<html><script>n=u=v=0
function i(){t=document.body.lastChild.getContext('2d')
t.fillStyle='green'
r=Math.random()*99
x=u,y=v
u=x*.85+y/25,v=y*.85-x/25+1.6
if(r<14)u=y/3-x/7,v=x/4+y/4+.4
if(r<7)u=x/5-y/4,v+=1.3
if(r<1)u=0,v=y/6
t.fillRect(50*u+140,525-50*v,1,1)
if(n<2e5)if(n++%99)i()
else setTimeout(i,1)}onload=i</script><canvas height=550></html>


Works on modern browsers (well, ok, works on Firefox and probably Chrome). It's also 348 bytes. Can anyone do better?

Name: Anonymous 2009-06-14 14:55

>>28
The contents of the while loop can be re-written as a single comma-deliminated statement, making the brackets on the loop unnecessary.
285 bytes.

<html><body onload="n=u=v=0;t=document.body.lastChild.getContext('2d');t.fillStyle='#070';while(n++<2e5)r=Math.random()*99,r<14?r<1?(u=0,v/=6):v=u/4+v/4+(r<7?(u=u/5-v/4,1.7):(u=v/3-u/7,.4)):u=u*.85+v/25+0*(v=v*.85-u/25+1.6),t.fillRect(50*u+140,525-50*v,1,1)"><canvas height=550></html>

and a data:uri
data:text/html;charset=utf-8;base64,PGh0bWw+PGJvZHkgb25sb2FkPSJuPXU9dj0wO3Q9ZG9jdW1lbnQuYm9keS5sYXN0Q2hpbGQuZ2V0Q29udGV4dCgnMmQnKTt0LmZpbGxTdHlsZT0nIzA3MCc7d2hpbGUobisrPDJlNSlyPU1hdGgucmFuZG9tKCkqOTkscjwxND9yPDE/KHU9MCx2Lz02KTp2PXUvNCt2LzQrKHI8Nz8odT11LzUtdi80LDEuNyk6KHU9di8zLXUvNywuNCkpOnU9dSouODUrdi8yNSswKih2PXYqLjg1LXUvMjUrMS42KSx0LmZpbGxSZWN0KDUwKnUrMTQwLDUyNS01MCp2LDEsMSkiPjxjYW52YXMgaGVpZ2h0PTU1MD48L2h0bWw+

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List