663 points · by wlll · 14y ago · 66 comments
http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/...
I was surprised to see not just equations but actual C code -- a pretty readable paper.
I've done more serious touching of it, for performance reasons -- taking mults and invariants out of loops, or memoizing for example -- but I always ended up either breaking it or making it slower, so for now I've settled with leaving it alone!
font-family: "Courier New";
Not everybody has Courier New installed, and some people who have it installed have disabled it. If the browser can't find a named font, it falls back on the default, which is usually proportional Instead, if you say: font-family: monospace;
...that's less characters to type, and it guarantees you'll get some kind of monospaced font, no matter what the user has available.[1]: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/...
If you do end up making that, shoot me a message.
I might have to do it now that this guy has inspired me.
Very cool however!
// forget about IE, just forget about it
I just thought that was hilarious.Secondly, I couldn't resist playing around with this a bit. I added a few UI components - allowing the user to change the ascii characters used, the color of the text, removes the dialog box after a period of time, and binding the clear feature to the space bar. All of which I felt like made it a little more fun for me to play with in full-screen mode.
Here is a link to my modified version for fun: http://www.johnmick.net/fluids/
Annoyingly I didn't make a note of where I found the algorithm and I can't find the source now, but I remember being struck by its simplicity and deciding I had to find a use for it.
The meat of it is:
z = (sum of surrounding cells) - z;
z -= z >> 5;
Does anybody recognise it?Sod's law, 10 minutes after posting I think I've found it, http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
We need more things like this in JS :D
Apparently it pissed off hacker news for me to say so judging by the downvotes but I'm leaving it.
It's very cool stuff.
And I don't think all programming has to have an immediate practical application. In fact I wish more of us were doing stuff like this. Practically every 30-something hacker I know was doing graphics demos in the early 90s.
I guess people thought I was saying any 13 year old could do this or something.
* shrug