Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattdiamond
Created May 15, 2014 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdiamond/8142ae7fed45c99d01cf to your computer and use it in GitHub Desktop.
Save mattdiamond/8142ae7fed45c99d01cf to your computer and use it in GitHub Desktop.
Curlicue Fractal
<!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