public
Created — forked from aemkei/LICENSE.txt

Lorenz Attractor - 140byt.es

  • Download Gist
LICENSE.txt
1 2 3 4 5 6 7 8 9 10 11 12 13
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
 
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
 
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
 
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
0. You just DO WHAT THE FUCK YOU WANT TO.
README.md
Markdown

Lorenz Attractor - 140byt.es

The Lorenz Attractor is a fractal structure corresponding to the long-term behavior of the Lorenz oscillator.

The Lorenz oscillator is a 3-dimensional dynamical system that exhibits chaotic flow, noted for its lemniscate shape.

Check out the example!

For more information

See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.

To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.

140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.

annotated.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
function(
h, // some
a, // ... magic
b, // ... arguments
c,
x, // x coord
y, // y coord
z, // z coord
j // callback to pass x,y,z
){
setInterval( // run in cycles
function(){
j( // execute callback
x+=h*a*(y-x), // and pass new coords
y+=h*(x*(b-z)-y), // calculate new values
z+=h*(x*y-c*z)
)
}, 9)
}
index.js
JavaScript
1
function(h,a,b,c,x,y,z,j){setInterval(function(){j(x+=h*a*(y-x),y+=h*(x*(b-z)-y),z+=h*(x*y-c*z))},9)}
package.json
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13
{
"name": "lorenzAttractor",
 
"description": "A 3-dimensional dynamical system that exhibits chaotic flow.",
 
"keywords": [
"math",
"3d",
"oscillator",
"visual",
"animation"
]
}
test.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<!DOCTYPE html>
<title>Foo</title>
<body></body>
<a href="https://gist.github.com/1320178">Source code</a>
<style type="text/css" media="screen">
html {
background: #666;
position: relative;
}
a {
bottom: 10px;
left: 10px;
position: absolute;
}
body {
width: 500px;
height: 500px;
background: white;
}
div {
background-color: #069;
opacity: 0.5;
width: 5px;
height: 5px;
overflow: hidden;
display: block;
position: absolute;
margin: 250px 250px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
}
</style>
 
<script>
 
var lorenz =
function(h,a,b,c,x,y,z,j){setInterval(function(){j(x+=h*a*(y-x),y+=h*(x*(b-z)-y),z+=h*(x*y-c*z))},9)}
 
function init(){
var max = 1000, i = 0, divs = [];
 
for (i=0; i < max; i++){
div = document.createElement("div");
divs.push(div);
document.body.appendChild(div);
}
 
function callback(x,y,z){
divs[i=(i+1)%max].style.cssText =
"left:" + (x*8) + "px;" +
"top:" + (y*8) + "px;" +
"width:" + Math.abs(z/4) + "px;" +
"height:" + Math.abs(z/4) + "px;"
}
 
lorenz(0.008,10,28,8/3,0,10,10,callback);
}
 
 
init();
</script>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.