Created
May 15, 2014 02:28
-
-
Save mattdiamond/8142ae7fed45c99d01cf to your computer and use it in GitHub Desktop.
Curlicue Fractal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset='utf-8'> | |
<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/paper.js/0.9.18/paper-core.min.js'></script> | |
<script type='text/javascript'> | |
paper.install(window); | |
window.onload = function(){ | |
myCanvas.width = window.innerWidth; | |
myCanvas.height = window.innerHeight; | |
paper.setup('myCanvas'); | |
path = new Path({ strokeColor : 'black'}); | |
path.add(view.center); | |
var angle = 0, i = 0, iter = 20, constant = Math.SQRT1_2; | |
view.onFrame = function(){ | |
for (var x = 0; x < iter; x++){ | |
var vector = new Point({ | |
angle: -angle * (180 / Math.PI), | |
length: 10 | |
}); | |
path.lineBy(vector); | |
angle = angle + 2 * Math.PI * ++i * constant; | |
} | |
if (!view.bounds.contains(path.bounds)) view.zoom *= 0.99; | |
}; | |
} | |
</script> | |
<style type='text/css'> | |
html, body { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
canvas { | |
float: left; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id='myCanvas'></canvas> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment