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 16:50

turn it into a base 60 encoded url now faggots

Name: Anonymous 2009-06-14 17:04

The quotes around the onload aren't necessary now that you've removed all the spaces.

247 bytes.

<body onload=n=u=v=0;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),document.body.lastChild.getContext('2d').fillRect(50*u+140,525-50*v,1,1)><canvas height=550>

and the data: uri
data:text/html;charset=utf-8;base64,PGJvZHkgb25sb2FkPW49dT12PTA7d2hpbGUobisrPDJlNSlyPU1hdGgucmFuZG9tKCkqOTkscjwxND9yPDE/KHU9MCx2Lz02KTp2PXUvNCt2LzQrKHI8Nz8odT11LzUtdi80LDEuNyk6KHU9di8zLXUvNywuNCkpOnU9dSouODUrdi8yNSswKih2PXYqLjg1LXUvMjUrMS42KSxkb2N1bWVudC5ib2R5Lmxhc3RDaGlsZC5nZXRDb250ZXh0KCcyZCcpLmZpbGxSZWN0KDUwKnUrMTQwLDUyNS01MCp2LDEsMSk+PGNhbnZhcyBoZWlnaHQ9NTUwPg==

Name: Anonymous 2009-06-14 17:12

247 bytes.
<body onload="n=u=v=0;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),document.body.lastChild.getContext('2d').fillRect(50*u+140,525-50*v,1,1)"><canvas height=550>

Name: Anonymous 2009-06-14 17:13

>>43
oops, wrong one.
<body onload=n=u=v=0;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),document.body.lastChild.getContext('2d').fillRect(50*u+140,525-50*v,1,1)><canvas height=550>

Name: FrozenVoid 2009-06-14 17:13

242 bytes, only canvas, but you have to click on it to show the fern.
<canvas height=550 onclick=n=u=v=0;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),document.body.lastChild.getContext('2d').fillRect(50*u+140,525-50*v,1,1)>


_____________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
orbis terrarum delenda est

Name: FrozenVoid 2009-06-14 17:16

<canvas height=550 onclick=n=u=v=0;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),this.getContext('2d').fillRect(50*u+140,525-50*v,1,1)>

using this, 223bytes



____________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
orbis terrarum delenda est

Name: Anonymous 2009-06-14 17:28

>>45
>>46

Cute, but don't work.

Name: FrozenVoid 2009-06-14 17:29

save the >>46 as .html, open with Firefox3
click on top-left corner, wait 3 seconds.

_______________________________
http://xs135.xs.to/xs135/09042/av922.jpg
orbis terrarum delenda est

Name: Anonymous 2009-06-14 17:37

>>48
turn it into a URL

Name: Anonymous 2009-06-14 17:38

The this. isn't actually necessary either. 218 bytes.

<canvas height=550 onclick=n=u=v=0;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),getContext('2d').fillRect(50*u+140,525-50*v,1,1)>

Name: Anonymous 2009-06-14 17:46

data:text/html;charset=utf-8;base64,PGNhbnZhcyBoZWlnaHQ9NTUwIG9uY2xpY2s9bj11PXY9MDt3aGlsZShuKys8MmU1KXI9TWF0aC5yYW5kb20oKSo5OSxyPDE0P3I8MT8odT0wLHYvPTYpOnY9dS80K3YvNCsocjw3Pyh1PXUvNS12LzQsMS43KToodT12LzMtdS83LC40KSk6dT11Ki44NSt2LzI1KzAqKHY9diouODUtdS8yNSsxLjYpLGdldENvbnRleHQoJzJkJykuZmlsbFJlY3QoNTAqdSsxNDAsNTI1LTUwKnYsMSwxKT4%3D

Name: Anonymous 2009-06-14 18:04

You should use double quotes instead of single quotes. Although they may look like they weigh more, in fact the ASCII value is less, and has fewer bits set.

Name: Anonymous 2009-06-14 18:04

>>50
That runs about 3 times as fast in Chrome than it does on Firefox trunk nightlies. Goddamn, they should just use V8. Fireshit is starting to hold the web back.

Name: Anonymous 2009-06-14 18:17

>>53
Firefox has never been a fast browser, what did you expect?

Name: Anonymous 2009-06-14 18:40

>>54
They claimed their "new" Tracemonkey JS engine was as fast or faster as V8. I have yet to see a single instance of that being true (it might be for some microbenchmark with some very tight invariant loop, but for any real program of reasonable size, it's a fucking failure)

Name: Anonymous 2009-06-14 19:30

>>55
it is faster for some microbenchmarks, but it fails horribly on anything that doesn't look like it was written by a FIOCfag.

Name: Anonymous 2009-06-14 19:45

>>56
What's the FIOCfag code writing craracteristic you're talking about? I don't think indentation can affect execution speed much

Name: Anonymous 2009-06-14 19:53

I imagine the <canvas> code is equally important here, though.

Name: Anonymous 2009-06-14 20:35

>>67
only doing one thing per line, never using more than two levels of nested loops or coditionals, and no functional programming.

Name: Anonymous 2009-06-14 21:14

>>59
Oddly enough, sans no functional programming functional programmers seem to foot this bill better than python programmers.
Hey guys, why would anyone use a conditional when they can simulate the effect by continuation passing curried $ applied arguments to a catamorphic functor who evaluates the given idempotent unary function parameter and folds it based on an independent data type with accompanying functor to ensure catamorphic conformance.

Name: Anonymous 2009-06-14 21:57

>>60
i don't think you understand the "only doing one thing per line" part...

n=0
u=0
v=0
n2e5 = n < 2e5
while(n){
    n = n + 1
    r = Math.random()
    r = r * 99
    r14 = r < 14
    if(r14){
        r1 = r < 1
        if(r1){
             u = 0
             v = v / 6} // Dammit braces are so ugly and redundant.
        else{
             v = v / 4
             u4 = u / 4
             v = v + u4
             r7 = r < 7
             if(r7){
                 u = u / 5
                 v4 = v / 4
                 u = u + v4
                 x = 1.7} // I really hate braces.
             else{
                 u = u / 7
                 v3 = v / 3
                 u = u + v3
                 x = 0.4 }
             v = v + x}} // Don't you hate braces too?
    else{
        u = u * 0.85
        v25 = v / 25
        u = u + v25
        v = v * 0.85
        u25 = u / 25
        v = v + u25
        v = v + 1.6} // Ok that's it if I have to type one more closing brace, I'm going to throw a huge tantrum until someone adds support for Python scripting to Firefox.
    u = u * 50
    u = u + 140
    v = v * 50
    v = 525 - v
    c = this.getContext('2d')
    c.fillRect(u, v, 1, 1)


except an FIOCfag split up into about 20 smaller functions so there's no more than two levels of loop/conditional nesting in each function instead of the four levels here.

Name: Anonymous 2009-06-15 13:26

How do you pronounce``FIOCfag''?
1) Fy-ock fag
2) Fee-ock fag
3) Eff Eye Oh See fag (faggot)
4) My other car is a cudder.

Name: Anonymous 2009-06-15 13:37

>>25
can be reduced by one byte to 322 by using a different way of defining functions

<html><body onload=n=u=v=0,t=document.body.lastChild.getContext('2d');i=function(){t.fillStyle='#070';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);n++<2e5?n%99?i():setTimeout(i,1):1};i()><canvas height=550></html>

Name: Anonymous 2009-06-15 16:53

>>63

281

<canvas height=550 onclick=n=u=v=0,t=getContext('2d'),t.fillStyle='#070';i=function(){r=Math.random()*99;r<14?r<1?(u=0,v/=6):v=v/4+u/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);n++<2e5?n%99?i():setTimeout(i,1):1};i()>

Name: Anonymous 2009-06-15 18:59

Posting in a marvellous thread.

Name: Anonymous 2009-06-15 20:34

>>50
You can save another byte by fucking with the mapping ratios. Slightly uglier, but still working quite well. 217 bytes.

<canvas height=550 onclick=n=u=v=0;while(n++<9e4)r=Math.random()*9,r<2?r<.1?(u=0,v/=6):v=u/4+v/4+(r<1?(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),getContext('2d').fillRect(50*u+140,525-50*v,1,1)>

Also
>>64
is 280 bytes.

Name: Anonymous 2009-06-16 3:52

the book can also be...a hat

Name: Anonymous 2009-06-16 15:12

>>66
In the interest of achieving a truly minimal snippet, here's a rotated and shrunk 192 byte version.

<canvas onclick=n=u=v=0;while(n++<3e4)r=Math.random()*9,r<2?r<.1?(u=0,v/=6):v=u/4+v/4+(r<1?(u=u/5-v/4,38):(u=v/3-u/7,9)):u=u*.85+v/25+0*(v=v*.85-u/25+42),getContext('2d').fillRect(v,u+60,1,1)>


Also, both "good" versions can be improved with no loss of quality by distributing the factors. Hence, a black-and-white non-animated 209 byte version:

<canvas height=550 onclick=n=u=v=0;while(n++<9e4)r=Math.random()*9,r<2?r<.1?(u=0,v/=6):v=u/4+v/4+(r<1?(u=u/5-v/4,80):(u=v/3-u/7,20)):u=u*.85+v/25+0*(v=v*.85-u/25+80),getContext('2d').fillRect(u+140,525-v,1,1)>

and a green animated 272 byte version:

<canvas height=550 onclick=n=u=v=0,t=getContext('2d'),t.fillStyle='#070';i=function(){r=Math.random()*99;r<14?r<1?(u=0,v/=6):v=v/4+u/4+(r<7?(u=u/5-v/4,85):(u=v/3-u/7,20)):u=u*.85+v/25+0*(v=v*.85-u/25+80);t.fillRect(u+140,525-v,1,1);n++<2e5?n%99?i():setTimeout(i,1):1};i()>

Name: Anonymous 2009-06-16 18:12

Benchmark:

<canvas height=550 onclick="start=(new Date).getTime();n=u=v=0;while(n++<9e4)r=Math.random()*9,r<2?r<.1?(u=0,v/=6):v=u/4+v/4+(r<1?(u=u/5-v/4,80):(u=v/3-u/7,20)):u=u*.85+v/25+0*(v=v*.85-u/25+80),getContext('2d').fillRect(u+140,525-v,1,1);alert((new Date).getTime()-start)">

Results:

Firefox trunk (3.6a1pre), Tracemonkey: 3579 ms
Firefox trunk (3.6a1pre), no Tracing: 3523 ms
Chrome trunk (3.0.189.0), V8: 1501 ms

Name: Anonymous 2009-06-16 18:54

Turn it into a URL

Name: Anonymous 2009-06-16 19:11

>>70
Leave.

Name: Anonymous 2009-06-23 3:44

Bumping an old thread because I have nothing to contribute.

Name: Anonymous 2009-06-23 4:16

this is the second to top result when googling "wiki Minimal Barnsley's Fern" (without quotes)

Name: Anonymous 2009-06-23 4:18



    Turn it into a URL

Name: Anonymous 2009-06-23 5:57

>>73
Some hacker artists create art by writing computer code, and others, by developing hardware. Some create with existing software tools such as Adobe Photoshop or GIMP.1
____________
http://en.wikipedia.org/wiki/Hacker_artist

Name: Turn it into a URL 2009-06-23 6:06

    Turn it into a URL

Name: Anonymous 2009-06-23 8:02




        Turn it into a URL

        Turn it into a URL


        Turn it into a URL

Name: Anonymous 2009-06-23 8:13

I will paste it into my URL bar and then it will draw a fern.

Name: FrozenVoid 2009-06-23 8:33

>>78
create "test.html" write the <canvas stuff in and open with Firefox. Not rocket science
Base64 is actually b]larger[/b] then normal text,so you don't save space by it.

______________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
orbis terrarum delenda est

Name: Anonymous 2009-06-23 12:26

>>79
then normal text
Then what!?!

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