Skip to content

Instantly share code, notes, and snippets.

@felipap
Last active December 19, 2015 17:48
Show Gist options
  • Save felipap/5993616 to your computer and use it in GitHub Desktop.
Save felipap/5993616 to your computer and use it in GitHub Desktop.
Hénon attractor
<!DOCTYPE html>
<html>
<head>
<style>
canvas { border: 1px solid #DDD; }
</style>
</head>
<canvas width=1500 height=1000></canvas>
<script>
var ctx = document.querySelector('canvas').getContext('2d'),
k = {x: 400, y:800},
center = {x: 600, y:500},
x = y = 0,
a = 1.4, b = 0.3;
setInterval(function draw() {
ctx.fillRect(center.x+x*k.x, center.y-y*k.y, 1, 1);
var _x = x;
x = y+1-(a*_x*_x);
y = b*_x;
}, 1);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment