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

Pages: 1-4041-8081-120121-

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-13 17:35

HAY GUYS WHAT DOES IT DO IM SCARED TO RUN IT

Name: Anonymous 2009-06-13 17:50

WHY DIDN'T YOU CLOSE THE <canvas> TAG YOU FAGGOT

Name: Anonymous 2009-06-13 17:59

Name: Anonymous 2009-06-13 18:21

data:text/html;base64,PGh0bWw+PHNjcmlwdD5uPXU9dj0wCmZ1bmN0aW9uIGkoKXt0PWRvY3VtZW50LmJvZHkubGFzdENoaWxkLmdldENvbnRleHQoJzJkJykKdC5maWxsU3R5bGU9J2dyZWVuJwpyPU1hdGgucmFuZG9tKCkqOTkKeD11LHk9dgp1PXgqLjg1K3kvMjUsdj15Ki44NS14LzI1KzEuNgppZihyPDE0KXU9eS8zLXgvNyx2PXgvNCt5LzQrLjQKaWYocjw3KXU9eC81LXkvNCx2Kz0xLjMKaWYocjwxKXU9MCx2PXkvNgp0LmZpbGxSZWN0KDUwKnUrMTQwLDUyNS01MCp2LDEsMSkKaWYobjwyZTUpaWYobisrJTk5KWkoKQplbHNlIHNldFRpbWVvdXQoaSwxKX1vbmxvYWQ9aTwvc2NyaXB0PjxjYW52YXMgaGVpZ2h0PTU1MD48L2h0bWw+Cg==

Name: Anonymous 2009-06-13 18:26

>>3
Why would you? It's like an image tag, basically. You can close it, but you don't need to, and not doing so saves nine bytes.

Name: Anonymous 2009-06-13 18:52

>>6
More like two, can't you do <canvas ... />?

Name: Anonymous 2009-06-14 0:29

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

Name: Anonymous 2009-06-14 1:35

>>8
348 bytes - 13 bytes (<html> and </html>) - 1 byte (removing i and moving onload= == 334 bytes

r<14?r<1?(u=0,v=y/6):(v=x/4+y/4+(r<7?(u=x/5-y/4,1.7):(u=y/3-x/7,.4))):(u=x*.85+y/25,v=y*.85-x/25+1.6)
that is exactly the same length, but it's more efficient, so it is an improvement.

Name: Anonymous 2009-06-14 2:30

>>9
Wow, that's a hell of a conditional statement. Nice catch on moving the onload, too.

You can actually save another 8 bytes by using a conditional in place of the last if-else, too:
[code]<html><script>n=u=v=0
onload=function i(){t=document.body.lastChild.getContext('2d')
t.fillStyle='green'
r=Math.random()*99
x=u,y=v
r<14?r<1?(u=0,v=y/6):(v=x/4+y/4+(r<7?(u=x/5-y/4,1.7):(u=y/3-x/7,.4))):u=x*.85+y/25,v=y*.85-x/25+1.6
t.fillRect(50*u+140,525-50*v,1,1)
if(n<2e5)n++%99?i():setTimeout(i,1)}</script><canvas height=550></html>[code]

Name: Anonymous 2009-06-14 2:38

>>10
And a further byte by doing the same for the other end-of-function if, actually, for a total of 325 or 338, depending on whether you leave the <html> tags in.

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

Name: Anonymous 2009-06-14 2:51

You can save additional bytes by using 'red' instead of 'green'

Name: FrozenVoid 2009-06-14 4:32

saving extra bytes  is useless. Benchmark it for speed.



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

Name: Anonymous 2009-06-14 4:34

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


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

Name: Anonymous 2009-06-14 7:16


r<14?r<1?(u=0,v=y/6):(v=x/4+y/4+(r<7?(u=x/5-y/4,1.7):(u=y/3-x/7,.4))):(u=x*.85+y/25,v=y*.85-x/25+1.6)


Okay, but nested if/else would be nicer to read.

Name: Anonymous 2009-06-14 10:10

>>14
When setting the fillStyle, at least in Firefox, you have to use a # before the 070 to get it to work. Still saves one byte, though.

You can save some more by eliminating the y=v - the particular way >>8 wrote the conditional statement makes it redundant.

Also, v=y/6 can be replaced by v/=6.

332 bytes.

<html><script>n=u=v=0
onload=function i(){t=document.body.lastChild.getContext('2d')
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))):(x=u,u=x*.85+v/25,v=v*.85-x/25+1.6)
t.fillRect(50*u+140,525-50*v,1,1)
n<2e5?n++%99?i():setTimeout(i,1):1}</script><canvas height=550></html>

Name: Anonymous 2009-06-14 11:22

I tested in Firefox 3.5 and Chrome, IE doesn't think body.lastChild exists in the calling context and firebug keeps crashing firefox whenever I try and figure out why.

<body onload="n=u=v=0,t=document.body.lastChild.getContext('2d');function i(){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))):(x=u,u=x*.85+v/25,v=v*.85-x/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>

Name: Anonymous 2009-06-14 11:34

>>16
331 bytes.

<html><script>n=u=v=0
onload=function i(){t=document.body.lastChild.getContext('2d')
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))):(x=u,u=x*.85+v/25,v=v*.85-x/25+1.6)
t.fillRect(50*u+140,525-50*v,1,1)
n++<2e5?r<1?i():setTimeout(i,1):1}</script><canvas height=550></html>

Name: Anonymous 2009-06-14 11:40

>>17
it doesn't work in lynx either.
modern browsers

also, why would you even try to use firebug? it's never done anything for me except crash firefox, since it was first released.

Name: Anonymous 2009-06-14 11:40

>>17
IE doesn't support the canvas element.

Two bytes can be saved by removing a set of parentheses in the conditional statement.

<html><body onload="n=u=v=0,t=document.body.lastChild.getContext('2d');function i(){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)):(x=u,u=x*.85+v/25,v=v*.85-x/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-14 11:41

>>19
Because the IE8 script debugger also crashes, and firebug is the best in the business.

Name: Anonymous 2009-06-14 11:50

>>18
The problem with using r for your check to do the timeout is that it's, well, random. You'll probably run in to the "too much recursion" eventually, which is what the timeout is there to prevent.

Also, given that your code uses the timeout in 99 out of 100 cases, you may as well just use
n++<2e5?setTimeout(i,1):1, which does always work, just very, very slowly. Your code probably meant r>1 instead of r<1, although that does have a much higher chance of running into "too much recursion".

Name: Anonymous 2009-06-14 11:54

>>22
Would setTimeout(i,0) not work better, it will behave the same except for not actually recursing but starting a new thread every time.

Name: Anonymous 2009-06-14 12:10

>>23
The speed increase by waiting 0 milliseconds instead of 1 is minimal. Given that you're only calling setTimeout every 99th time, and that you have only 2e5 calls to i, you only save 2.02 seconds. Most of the wait is from the fact that setTimeout(i,0) takes a lot more time to get called than i().

Name: Anonymous 2009-06-14 13:03

Another two bytes can be saved by rephrasing (x=u,u=x*.85+v/25,v=v*.85-x/25+1.6) to u=u*.85+v/25+0*(v=v*.85-u/25+1.6), which doesn't need the parentheses. It's now 323 bytes, and I doubt it's going to get much smaller.

<html><body onload="n=u=v=0,t=document.body.lastChild.getContext('2d');function i(){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,0):1}i()"><canvas height=550></html>

Name: Anonymous 2009-06-14 14:02

I'm going to write a lisp program that brute forces every combination of characters of less than 323 bytes until it finds a shorter solutions

Name: Anonymous 2009-06-14 14:24

I have written a variant of XHTML that has a tag specifically for Barnsley's Fern:

<fern/>

As usual, a DSL gives a more elegant solution.

Name: FrozenVoid 2009-06-14 14:38

287 bytes:
<html><body onload="n=u=v=0;t=document.body.lastChild.getContext('2d');t.fillStyle='#C40';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>


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

Name: Anonymous 2009-06-14 14:39

>>27
What attributes can it have?

Name: FrozenVoid 2009-06-14 14:49

type into address bar:
javascript:window.open(['data:text/html,<html><body onload="',"n=u=v=0;t=document.body.lastChild.getContext('2d');t.fillStyle='#C40';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>'].join(""),'a');

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

Name: Anonymous 2009-06-14 14:53

>>30
I think the point originally was that we could watch it being drawn and understand the chaos game, not to butcher the process with some ugly iterative crap.

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+

Name: FrozenVoid 2009-06-14 15:06

[jp]
           ';:::::::::::::::::::::::::'、     /:::::::::::::::::::',
         ':;::::::::::::::::::::::::',     /::::l:::::::::::::::::::::l
            ヽ;::_;_/⌒l:::::'、   !::::::|:::::::::::::::::::::|
            ( rっ^ヽ::┴:::‐'::-:::ヘ::::::::::::::::::l
            f´ ~ 、_.ノ:::::::::::::::::::::::::ヽ:;:_::_::ノ
           /`:ー:':::::::;:: ‐ ´  ̄ ` ヽ:;ヽ、
          /::::::::::::::/-―-、__,    ヾ:':,
            !::::::::::::/  '叨¨ヽ   `ー-、 l::l
          l::::::::::::l    ` ー    /叨¨) l::!
            !::::::::::l         ヽ,   リ
            ヽ::::::::',、   `ヽ.___´,   /
           ` -:::_ヽ、    `ニ´ _ .ィ´
[/jp]

Name: FrozenVoid 2009-06-14 15:25

>>32
284 bytes:
<html><body onload="n=u=v=0;t=document.body.lastChild.getContext('2d');t.fillStyle='red';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>

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

Name: Anonymous 2009-06-14 15:35

This is turning into a real pissing contest.

Name: Anonymous 2009-06-14 15:37

>>34
saving extra bytes  is useless.
- FrozenVoid

Name: FrozenVoid 2009-06-14 15:50

>>36 It is useless, but you insist on measuring the worth of program by it.

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

Name: Anonymous 2009-06-14 16:25

>>34
Red is only marginally better than black. At that point you may as well just use the 262 byte

<html><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></html>

But it's strayed pretty far from the original, now.

Name: FrozenVoid 2009-06-14 16:32

If for example you run a site with 150kb javascript file,
you could consider to compress it manually,if server gzip isn't enough.
There even programs which would reduce size by automatically compressing redundant text: http://en.wikipedia.org/wiki/Minification_%28programming%29
This isn't the case for it, however, since the program is already very small, smaller then minimum 576 IP packet.
_________________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
orbis terrarum delenda est

Name: FrozenVoid 2009-06-14 16:41

>>38 Okay, i'm removing the html then:
249 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>



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

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!?!

Name: FrozenVoid 2009-06-23 13:15

>>80 larger then normal text


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

Name: THEN NOMAD MEME FAN 2009-06-23 13:22

>>81
larger >> normal next
Makes no sense!

Name: Anonymous 2009-06-23 14:18

>>81
than

url:
data:text/html;charset=utf-8,<canvas height%3D550 onclick%3Dn%3Du%3Dv%3D0%2Ct%3DgetContext('2d')%2Ct.fillStyle%3D'%23070'%3Bi%3Dfunction(){r%3DMath.random()*99%3Br<14%3Fr<1%3F(u%3D0%2Cv/%3D6)%3Av%3Dv/4+u/4+(r<7%3F(u%3Du/5-v/4%2C85)%3A(u%3Dv/3-u/7%2C30))%3Au%3Du*.85+v/25+0*(v%3Dv*.85-u/25+80)%3Bt.fillRect(u+140%2C525-v%2C1%2C1)%3Bn++<2e5%3Fn%2599%3Fi()%3AsetTimeout(i%2C1)%3A1}%3Bi()>

Name: Anonymous 2009-06-23 14:19

>>81
So you're saying first it's larger, then it's normal?

Name: Anonymous 2009-06-23 15:22

>>83
SUPER COOL FERN BRO!

Name: Anonymous 2010-12-17 1:35

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-12-04 13:18

Bump for ancient autism

Name: Anonymous 2011-12-04 14:00

>>83
javascript: and data: URIs typed or pasted in the address bar are disabled to prevent social engineering attacks.

Name: Anonymous 2011-12-04 16:25

If Frozen spent as much time optimizing the fern code as he did with quasicrystals we would have fractals at x100 speed and all IFS code would be made obsolete.

Name: Anonymous 2011-12-04 16:37

>>92
I don't get it, how optimizing ten lines of this fern==speeds up fractals?
It doesn't look that optimizable anyway.

Name: Anonymous 2011-12-04 16:40

>>92
Go away.

Name: Anonymous 2011-12-04 18:31

>>94
fuck you antirussian racist piece of shit

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-04 23:55

That fern code is horribly unoptimized, i'll check the formulas later. There are ways to optimize anything >>93

Name: ᴠɪʟᴇ !PRoGN.piPE 2011-12-05 1:21

>>96, >>93
there are ways to optimise anything down to '()

Name: Anonymous 2011-12-05 2:26

>>97
lisp is shit

Name: Anonymous 2011-12-05 3:59

>>98
Doubt you're confident enough to judge.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 6:24

Initial refactoring 485ms(this is fullscreen fern)
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas width=550 id='frozenfern'><script>
   const  w=window.innerWidth
   const  h =window.innerHeight
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;

const green=0xff00ff00
context.fillStyle='green'

const iterations=100
var iter100=4000
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
var n=u=v=r=m=c=x=y=0;
var starttime=Date.now();
//longer syntax to run on old browser
function r99(){return Math.random()*99;}
function rord(){return Math.random()>0.5?1:0;}
    function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}
rn=Array(iterations);rn[0]=0;var elm
for(i=1;i<7;i++)rn[i]=1;
for(i=7;i<14;i++)rn[i]=2;
for(i=14;i<(iterations+1);i++)rn[i]=3;
rn.sort(rord);
var arrn=Uint32Array(w*h)


onload=function(){
while(iter100--){
rn.sort(rord)
n=iterations;
while(n--){
x=u;
y=v
switch(rn[n]){
case 3:;
u=x*xyred+y*a25;
v=y*xyred-x*a25+zoom;
break;
case 2:;
u=y*a3-x*a7;
v=(x+y)*a4+Hzoom;break;
case 1:;
u=x*a5-y*a4;
v=(x+y)*a4+Hzoom+Wzoom;break;
case 0:;u=0;
v=y*a6;break;
default:;;break;
}

arrn[(((mult*u+L))|0)+((H-mult*v)|0)*w]=green
//context.fillRect(mult*u+L,H-mult*v,1,1)
}};
co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)};
context.putImageData(co,0,0);
addtm(" ms h:"+h+" w:"+w);
};

</script></body></html>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 6:34

for comparison the 14443ms original 1/4 size fern
<html><script>n=u=v=0;start=Date.now()
function i(){if(n>=2e5)document.title+=Date.now()-start+" ms"
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>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 6:54

150ms not using sort
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas width=550 id='frozenfern'><script>
   const  w=window.innerWidth
   const  h =window.innerHeight
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;

const green=0xff00ff00
context.fillStyle='green'

const iterations=100
var iter100=4000
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
var n=u=v=r=m=c=x=y=0;
var starttime=Date.now();
//longer syntax to run on old browser
function r99(){return Math.random()*99;}
function rord(){return Math.random()>0.5?1:0;}
    function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}
rn=Array(iterations);rn[0]=0;var elm
for(i=1;i<7;i++)rn[i]=1;
for(i=7;i<14;i++)rn[i]=2;
for(i=14;i<(iterations+1);i++)rn[i]=3;
rn.sort(rord);
var arrn=Uint32Array(w*h)


onload=function(){
while(iter100--){
n=iterations;
while(n--){
x=u;
y=v
switch(rn[(Math.random()*99)|0]){
case 3:;
u=x*xyred+y*a25;
v=y*xyred-x*a25+zoom;
break;
case 2:;
u=y*a3-x*a7;
v=(x+y)*a4+Hzoom;break;
case 1:;
u=x*a5-y*a4;
v=(x+y)*a4+Hzoom+Wzoom;break;
case 0:;u=0;
v=y*a6;break;
default:;;break;
}

arrn[(((mult*u+L))|0)+((H-mult*v)|0)*w]=green
//context.fillRect(mult*u+L,H-mult*v,1,1)
}};
co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)};
context.putImageData(co,0,0);
addtm(" ms h:"+h+" w:"+w);
};

</script></body></html>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 7:55

134ms faster Random()
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas width=550 id='frozenfern'><script>
   const  w=window.innerWidth
   const  h =window.innerHeight
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;

const green=0xff00ff00
context.fillStyle='green'
const rnd=Math.random
const iterations=100
var iter100=4000//2000 too low quality
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHZoom=Wzoom+Hzoom
var n=u=v=r=m=c=x=y=0;
var starttime=Date.now();
//longer syntax to run on old browser
function r99(){return Math.random()*99;}
function rord(){return Math.random()>0.5?1:0;}
    function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}

var x3 = 123456789, y3 = 362436069, z3 = 521288629, w3 = 88675123,t3=0;
function xor128() {
  t3 = x3 ^ (x3 << 11);
  x3 = y3; y3 = z3; z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
  return w3
}

function rxor(){
  t3 = x3 ^ (x3 << 11);
  x3 = y3; y3 = z3; z3 = w3;
  w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3-(99*((w3/99)|0))
}

var arrn=Uint32Array(w*h)
onload=function(){
while(iter100--){
n=iterations;
while(n--){
x=u;
y=v
r=rxor()// rnd()*99;
if(r>=14){
u=x*xyred+y*a25;
v=y*xyred-x*a25+zoom;
}else{
if(r>=7){u=y*a3-x*a7,v=(x+y)*a4+Hzoom;}else{
if(r>=1){u=x*a5-y*a4,v=(x+y)*a4+WHZoom;}else{
u=0,v=y*a6}}}
arrn[(((mult*u+L))|0)+((H-mult*v)|0)*w]=green

}};
var co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)};
context.putImageData(co,0,0);
addtm(" ms h:"+h+" w:"+w);
};

</script></body></html>

Name: Anonymous 2011-12-05 8:09

Two years and no one has done it in Asm?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 8:14

91ms slightly different fern style(tree-like): >>104 the fern code is from early 90's when IFS algorithms was invented
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas width=550 id='frozenfern'><script>
   const  w=window.innerWidth
   const  h =window.innerHeight
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;

const green=0xff00ff00
context.fillStyle='green'
const rnd=Math.random
const iterations=100
const RW=50//Random walk range
var iter100=2000//2000 too low quality
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHZoom=Wzoom+Hzoom
var n=u=v=r=m=c=x=y=0;
var starttime=Date.now();
//longer syntax to run on old browser
function r99(){return Math.random()*99;}
function rord(){return Math.random()>0.5?1:0;}
    function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}

var x3 = 123456789, y3 = 362436069, z3 = 521288629, w3 = 88675123,t3=0;
function xor128() {
  t3 = x3 ^ (x3 << 11);
  x3 = y3; y3 = z3; z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
  return w3
}

function rxor(){
  t3 = x3 ^ (x3 << 11);
  x3 = y3; y3 = z3; z3 = w3;
  w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3-(RW*((w3/RW)|0))
}

var arrn=Uint32Array(w*h)
onload=function(){
while(iter100--){
n=iterations;
while(n--){
x=u;
y=v
t3 = x3 ^ (x3 << 11);
x3 = y3; y3 = z3; z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
r=w3-(RW*((w3/RW)|0))
if(r>=14){
u=x*xyred+y*a25;
v=y*xyred-x*a25+zoom;
}else{
if(r>=7){u=y*a3-x*a7,v=(x+y)*a4+Hzoom;}else{
if(r>=1){u=x*a5-y*a4,v=(x+y)*a4+Wzoom+Hzoom;}else{
u=0,v=y*a6}}}


arrn[(((mult*u+L))|0)+((H-mult*v)|0)*w]=green

}};
var co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)};
context.putImageData(co,0,0);
addtm(" ms h:"+h+" w:"+w);
};

</script></body></html>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 9:13

87ms minor fix to display
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas  id='frozenfern'><script>
   const  w=window.innerWidth
   const  h =window.innerHeight
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;

const green=0xff00ff00
context.fillStyle='green'
const iterations=100
const RW=50//Random walk range
var iter100=2000//Fill Quality(optimal ~4k)
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHZoom=Wzoom+Hzoom
var n=u=v=r=m=c=x=y=0;
var starttime=Date.now();

 function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}

var x3 = 123456789, y3 = 362436069, z3 = 521288629, w3 = 88675123,t3=0;
function rxor(){
  t3 = x3 ^ (x3 << 11);
  x3 = y3; y3 = z3; z3 = w3;
  w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3-(RW*((w3/RW)|0))
}

var arrn=Uint32Array(w*h)
while(iter100--){
n=iterations;
while(n--){
x=u;
y=v
t3 = x3 ^ (x3 << 11);
x3 = y3;
y3 = z3;
z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
r=w3-(RW*((w3/RW)|0))
if(r>=14){
u=x*xyred+y*a25;
v=y*xyred-x*a25+zoom;
}else{
if(r>=7){u=y*a3-x*a7,v=(x+y)*a4+Hzoom;}else{
if(r>=1){u=x*a5-y*a4,v=(x+y)*a4+Wzoom+Hzoom;}else{
u=0,v=y*a6}}}
arrn[(((mult*u+L))|0)+((H-mult*v)|0)*w]=green

}};

context.putImageData({width:w,height:h,data:Uint8ClampedArray(arrn.buffer)},0,0);
document.title+=Date.now()-starttime+" ms"



</script></body></html>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 9:52

83ms divide in random removed.
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas  id='frozenfern'><script>

   const  w=window.innerWidth
   const  h =window.innerHeight
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;

const green=0xff00ff00
const iterations=100
const RW=50//Random walk range
var iter100=2000//Fill Quality(optimal ~4k)
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHZoom=Wzoom+Hzoom
var n=u=v=r=m=c=x=y=0;
var starttime=Date.now();

function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}

var x3 = 123456789, y3 = 362436069, z3 = 521288629, w3 = 88675123,t3=0;
function rxor(){
  t3 = x3 ^ (x3 << 11);
  x3 = y3; y3 = z3; z3 = w3;
  w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3-(RW*((w3/RW)|0))
}

var arrn=Uint32Array(w*h)
while(iter100--){
n=iterations;
while(n--){
x=u;
y=v
t3 = x3 ^ (x3 << 11);
x3 = y3;
y3 = z3;
z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
r=(w3&255)>>2


if(r>13){
u=x*xyred+y*a25;
v=y*xyred-x*a25+zoom;
}else{
if(r>6){u=y*a3-x*a7;
v=(x+y)*a4+Hzoom;}else{
if(r>0){
u=x*a5-y*a4;
v=(x+y)*a4+Wzoom+Hzoom;}else{
u=0;v=y*a6}}}

arrn[(((mult*u+L))|0)+((H-mult*v)|0)*w]=green

}};

context.putImageData({width:w,height:h,data:Uint8ClampedArray(arrn.buffer)},0,0);
document.title+=Date.now()-starttime+" ms"



</script></body></html>

Name: Anonymous 2011-12-05 16:24

>>107
I get 333ms, what computer/OS/browser are you doing your tests on?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 23:11

>>108
Athlon II x2 240/Windows XP/Firefox 11.0a1(2011-12-03)

Name: Anonymous 2011-12-05 23:44

>>111
wow amazing triples bro

Name: Anonymous 2011-12-06 0:12

check 'em

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 5:12

The key seems to be making the random function deterministic.
I'm trying to convert it to some predictable sequence thats as fast as random one.

Name: Anonymous 2011-12-06 5:30

>>112
So javascript random is nondeterministic? OMG THEY DID IT

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 5:46

>>113
For all purposes Math.random()
1.won't get any predictable sequence
2.its way slower than using xorshift PRNG

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 5:55

The >>1 fern is non-deterministic : it create different fern each time its loaded
the recent bunch of fern are using xorshift and are deterministic:its the same fern all time

Name: Anonymous 2011-12-06 5:56

>>113
So javascript random is nondeterministic? OMG THEY DID IT
Soooo can we use javascript to emulate Nondeterministic Touring Machines and solve NP-complete problems in polynomial time? Infinite compression, here I come!

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 5:58

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 6:31

90ms version with new leaf functions: makes the code simpler.
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas  id='frozenfern'><script>

   const  w=window.innerWidth
   const  h =window.innerHeight
const M=w>h?w:h
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;
var DEBUG=1;
function d(x){if(!DEBUG)return;if(typeof(x)==Array){document.body.innerHTML+=(x.join(","))}else{document.body.innerHTML+=(x.toString())}}
const green=0xff00ff00
const blue=0xffff0000
const red=0xff0000ff
//const iterations=100
const RW=100//Random walk range
var iter100=2000//00//Fill Quality(optimal ~4k)
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHzoom=Wzoom+Hzoom
var starttime=Date.now();
function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}
var rands=Uint32Array(5);
var x3 =rands[0]= 123456789, y3 = rands[1]= 362436069, z3 =rands[2]=  521288629, w3 =rands[3]=  88675123,t3=rands[4];
var n=u=v=r=m=c=x=y=0;
var j=[]
//Stem 1/100
function stem(){
x=u;y=v;u=0;v=y*a6;
arrn[L+(     ((mult*u))|0   )+(H-(mult*v)|0)*w]=green;}
//xorshift rnd
function r63(){
t3 = x3 ^ (x3 << 11);
x3 = y3;
y3 = z3;
z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3&63}
//LeafSet
function setleafD(){x=u;y=v;
u=x*xyred+y*a25;v=y*xyred-x*a25+zoom;
arrn[L+(     ((mult*u))|0   )+(H-(mult*v)|0)*w]=green;}
function setleafW(){x=u;y=v;
u=x*a5-y*a4,v=(x+y)*a4+WHzoom;
arrn[L+(     ((mult*u))|0   )+(H-(mult*v)|0)*w]=blue;}
function setleafH(){x=u;y=v;
u=y*a3-x*a7,v=(x+y)*a4+Hzoom;
arrn[L+(     ((mult*u))|0   )+(H-(mult*v)|0)*w]=red;}
//Leaf
function leaf(){
var t;stem();
for(t=0;t<RW;t++){r=r63();
if((r&1)|(r&3)){setleafD();}else{if(r&7){setleafW()}else{setleafH()}}}}
//Main
var arrn=Uint32Array(w*h)
var co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)}
while(iter100--){leaf();};context.putImageData(co,0,0);
document.title+=Date.now()-starttime+" ms"
</script></body></html>

Name: Anonymous 2011-12-06 7:56

Name: Anonymous 2011-12-06 8:05

>>117
An algorithm that solves a problem in nondeterministic polynomial time can run in polynomial time or exponential time depending on the choices it makes during execution.
So if it makes the right choices, it can solve NP-complete problems in polynomial time! Just like infinite compression can compress data infinitely if it happens to be representable in a right way! Javascript is the most awesome language ever, I bet LISP can't be used for solving NP-complete problems!

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 8:23

>NP-complete problems
Fractal compression already exists, just its lossy. I think if IFS(non-determinstic) algorithm can be replaced by deterministic algorithm, this would simplify the problem into optimizations like preacaching/parameter reductions/simplified formulas/etc, which would make anything which uses IFS algorithms much more efficient(and compression would be deterministic too)

Name: Anonymous 2011-12-06 8:38

>>119
They cosplay the Start of David?

Name: Anonymous 2011-12-06 9:18

Canvas 2d Barnsley's Fern Generator http://jsdo.it/WallOfFire/f15l
Obviously superior

Name: Anonymous 2011-12-06 9:42

Name: Anonymous 2011-12-06 9:45

>>120
LITHP is a primitive, small subset of JavaScript. Only a LITHP fanatic would use it instead of more flexible and complete language.

Name: Anonymous 2011-12-06 9:51

>>123
It says it works on safari Chrome only....

Works in Opera too.

Name: Anonymous 2011-12-06 11:25

Barnsley fractal patents expire this year

Name: VIPPER 2011-12-06 12:40

>>124
Hes hot. I wouldnt mind having my as pounded by her.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 13:22

Unoptimized 678ms but now the fractal serves as its own PRNG(i.e. there is no external randomness or PRNG calls anymore)
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas  id='frozenfern'><script>

   const  w=window.innerWidth
   const  h =window.innerHeight
const M=w>h?w:h
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;
var DEBUG=1;
function d(x){if(!DEBUG)return;if(typeof(x)==Array){document.body.innerHTML+=(x.join(","))}else{document.body.innerHTML+=(x.toString())}}
var green=0xff00ff00
var blue=0xffff0000
var red=0xff0000ff
//const iterations=100
const RW=30000//Random walk range
var iter100=100//00//Fill Quality(optimal ~4k)
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//14//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHzoom=Wzoom+Hzoom
var starttime=Date.now();
function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}
var rands=Uint32Array(5);
var x3 =rands[0]= 123456789, y3 = rands[1]= 362436069, z3 =rands[2]=  521288629, w3 =rands[3]=  88675123,t3=rands[4];
var n=u=v=r=m=c=x=y=0;
var j=[]


//xorshift rnd
function r63(){
t3 = x3 ^ (x3 << 11);
x3 = y3;
y3 = z3;
z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3&63}
var wtable=Uint32Array(w);
for(var i=0;i<w;i++)wtable[i]=((H-i)*w)+L;

//Stem 1/100
function stem(){
x=u;y=v;u=0;v=y*a6;
arrn[wtable[(mult*v)|0]]=green;}
//LeafSet
function leafD(){
u=x*xyred+y*a25;v=y*xyred-x*a25+zoom;
arrn[((mult*u)|0)+wtable[(mult*v)|0]]=green;}
function leafW(){
u=x*a5-y*a4,v=(x+y)*a4+WHzoom;
arrn[((mult*u)|0)+wtable[(mult*v)|0]]=blue;}
function leafH(){
u=y*a3-x*a7,v=(x+y)*a4+Hzoom;
arrn[((mult*u)|0)+wtable[(mult*v)|0]]=red;}
//Leaf

function leaf(){;var t;stem()
for(t=0;t<RW;t++){
x=u;y=v;//r=r63();
r=(((u*v)*0xff)&63);
(r&1)|(r&3)?leafD():r&7?leafW():leafH();
};

}
//Main
var arrn=Uint32Array(w*h)
var co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)}
while(iter100--){
/* inlined version 3ms faster:
;stem();var t;
for(t=0;t<RW;t++){
x=u;y=v;r=r63();
((r&1)|(r&3))?(u=x*xyred+y*a25,v=y*xyred-x*a25+zoom):((r&7)?(u=x*a5-y*a4,v=(x+y)*a4+WHzoom):(u=y*a3-x*a7,v=(x+y)*a4+Hzoom));
arrn[L+(     ((mult*u))|0   )+(H-(mult*v)|0)*w]=green;}
*/
leaf();};//47ms
context.putImageData(co,0,0);//42ms
document.title+=Date.now()-starttime+" ms"
</script></body></html>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 13:55

*should be r=(((v+u*v)*0xff)&63); to avoid u=0

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 13:56

this version also messes up the stem, but doesn't detract quality.

Name: Anonymous 2011-12-06 13:57

USE CODE TAG, CODE FAG

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-06 14:09

68ms:optimized+ stem fix
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas  id='frozenfern'><script>

   const  w=window.innerWidth
   const  h =window.innerHeight
const M=w>h?w:h
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;
var DEBUG=1;
function d(x){if(!DEBUG)return;if(typeof(x)==Array){document.body.innerHTML+=(x.join(","))}else{document.body.innerHTML+=(x.toString())}}
var green=0xff00ff00
var blue=0xffff0000
var red=0xff0000ff
//const iterations=100
const RW=2000//Random walk range
var iter100=50//00//Fill Quality(optimal ~4k)
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//14//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHzoom=Wzoom+Hzoom
var starttime=Date.now();
function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}
var rands=Uint32Array(5);
var x3 =rands[0]= 123456789, y3 = rands[1]= 362436069, z3 =rands[2]=  521288629, w3 =rands[3]=  88675123,t3=rands[4];
var n=u=v=r=m=c=x=y=0;
var j=[]


//xorshift rnd
function r63(){
t3 = x3 ^ (x3 << 11);
x3 = y3;
y3 = z3;
z3 = w3;
w3 = w3 ^ (w3 >> 19) ^ (t3 ^ (t3 >> 8));
return w3&63}
var wtable=Uint32Array(w);
for(var i=0;i<w;i++)wtable[i]=((H-i)*w)+L;

//Stem 1/100
function stem(){
x=u;y=v;u=0;v=y*a6;
arrn[wtable[(mult*v)|0]]=green;}
//LeafSet
function leafD(){
u=x*xyred+y*a25;v=y*xyred-x*a25+zoom;
arrn[((mult*u)|0)+wtable[(mult*v)|0]]=green;}
function leafW(){
u=x*a5-y*a4,v=(x+y)*a4+WHzoom;
arrn[((mult*u)|0)+wtable[(mult*v)|0]]=blue;}
function leafH(){
u=y*a3-x*a7,v=(x+y)*a4+Hzoom;
arrn[((mult*u)|0)+wtable[(mult*v)|0]]=red;}
//Leaf

function leaf(){;var t;stem()
for(t=0;t<RW;t++){
x=u;y=v;//r=r63();
r=(((v+u*v)*0xff)&63);
if(r==0)stem();
(r&1)|(r&3)?leafD():(r&7?leafW():(leafH()));

};

}
//Main
var arrn=Uint32Array(w*h)
var co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)}
while(iter100--){
/* inlined version 3ms faster:
;stem();var t;
for(t=0;t<RW;t++){
x=u;y=v;r=r63();
((r&1)|(r&3))?(u=x*xyred+y*a25,v=y*xyred-x*a25+zoom):((r&7)?(u=x*a5-y*a4,v=(x+y)*a4+WHzoom):(u=y*a3-x*a7,v=(x+y)*a4+Hzoom));
arrn[L+(     ((mult*u))|0   )+(H-(mult*v)|0)*w]=green;}
*/
leaf();};//47ms
context.putImageData(co,0,0);//42ms
document.title+=Date.now()-starttime+" ms"
</script></body></html>

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-07 3:26

91ms randomizer reduced to union float:int
<html><head><style>html,body{width:100%;height:100%;margin:0px;}
    </style></head><body><canvas  id='frozenfern'><script>
   const  w=window.innerWidth
   const  h =window.innerHeight
const M=w>h?w:h
    var canv=document.getElementById('frozenfern');
    var context=canv.getContext("2d");
    canv.width=w ;
    canv.height=h ;
var DEBUG=1;
function d(x){if(!DEBUG)return;if(typeof(x)==Array){document.body.innerHTML+=(x.join(","))}else{document.body.innerHTML+=(x.toString())}}
const green=0xff00ff00
const blue=0xffff0000
const red=0xff0000ff
const purple=0xffff00ff
const yellow=0xff00ffff
var quality=200000
const H=h//525;
const L=w/2;//140
const mult=50;//
const xyred=0.85
const a25=1/25;
const a4=1/4;
const a3=1/3;
const a5=1/5;
const a7=1/7;
const a6=1/6
const a20=1/20
const zoom=2.8//14//1.6
const Hzoom=0.4
const Wzoom=1.3
const WHzoom=Wzoom+Hzoom
var starttime=Date.now();
function addtm(str){document.title+=Date.now()-starttime+str;starttime=Date.now()}
var x=y=0;
var farr=Float64Array(4)
var vars=Uint32Array(farr.buffer)
var wtable=Uint32Array(w);
for(var i=0;i<w;i++)wtable[i]=((H-i)*w)+L;
//Main
var color=green;
var arrn=Uint32Array(w*h)
var co={width:w,height:h,data:Uint8ClampedArray(arrn.buffer)}
while(quality--){
//u=farr[1],v=farr[0]
x=farr[1],y=farr[0];
(vars[1]&3)?(color=yellow,farr[1]=x*xyred+y*a25,farr[0]=y*xyred-x*a25+zoom):((vars[1]&7)?(color=red,farr[1]=x*a5-y*a4,farr[0]=(x+y)*a4+WHzoom):(color=blue,farr[1]=y*a3-x*a7,farr[0]=(x+y)*a4+Hzoom));
if((vars[0]&0xff)==0)farr[1]=0,farr[0]=y*a6,color=green;
arrn[ ( ((mult*farr[1]))|0)+wtable[(mult*farr[0])|0]]=color};
context.putImageData(co,0,0);//42ms
document.title+=Date.now()-starttime+" ms"
</script></body></html>

Name: Anonymous 2011-12-07 10:02

To the OP: Because most browsers clamp the minimum setTimeout/setInterval delay value to 10ms, even if you use a lower value, the upper bound is 100 timer-based function calls per second, which directly translates to a maximum of 100 pixels per second. If you were to fill multiple pixels in one call of i(), you could increase runtime speed.

Name: Anonymous 2011-12-07 10:19

>>135
The OP already draws 100 pixels for each timer event.

Name: Anonymous 2011-12-07 10:33

>>136
Bullshit!

Name: Anonymous 2011-12-07 11:21

>>137
are you blind!
if(n<2e5)if(n++%99)i()
else setTimeout(i,1)

Name: lol 2011-12-07 18:51

lulllllllllllz .im s0 hapy

Name: Anonymous 2011-12-07 19:42

RANDOM PROSESSES make me feel like i am everythnig the univeres was meant to be.

Name: Anonymous 2011-12-07 19:45

AHHHHHHHHHH I AM ONE WIT / NATURE & LOGIK

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