- Author:
- Daan van Berkel
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- dvberkel.github.io
- Compo:
- classic
- Demo link:
- https://js1k.com/2014-dragons/demo/1702
- Shortlink:
- https://js1k.com/1702
- Blog post:
- please update here!
- Bytes:
- 306
- Chars:
- 306
- Submission
(function(e,f,g,h,b,l){function k(){b.beginPath();b.moveTo(0,0);b.lineTo(e,0);b.stroke();var d=m++,d=0!==((d&-d)<<1&d);b.translate(e,0);d?b.rotate(f):b.rotate(-f);l(k)}b.translate(g(90*e,2*h.width/3),g(45*e,2*h.height/3));b.strokeStyle="black";var m=1;k()})(5,Math.PI/2,Math.min,a,c,requestAnimationFrame);
- Description
- Draws the classic Dragon curve fractal.
This demo draws the classic Dragon curve fractal line by line in a ever growing spiral. Note that the original source is also below the 1k mark.
- Base64 encoded
KGZ1bmN0aW9uKGUsZixnLGgsYixsKXtmdW5jdGlvbiBrKCl7Yi5iZWdpblBhdGgoKTtiLm1vdmVUbygwLDApO2IubGluZVRvKGUsMCk7Yi5zdHJva2UoKTt2YXIgZD1tKyssZD0wIT09KChkJi1kKTw8MSZkKTtiLnRyYW5zbGF0ZShlLDApO2Q/Yi5yb3RhdGUoZik6Yi5yb3RhdGUoLWYpO2woayl9Yi50cmFuc2xhdGUoZyg5MCplLDIqaC53aWR0aC8zKSxnKDQ1KmUsMipoLmhlaWdodC8zKSk7Yi5zdHJva2VTdHlsZT0iYmxhY2siO3ZhciBtPTE7aygpfSkoNSxNYXRoLlBJLzIsTWF0aC5taW4sYSxjLHJlcXVlc3RBbmltYXRpb25GcmFtZSk7
- Original source
(function(size, angle, minimum, canvas, context, requestAnimationFrame){
context.translate(minimum(90*size, 2*canvas.width/3), minimum(45*size, 2*canvas.height/3));
context.strokeStyle = 'black';
var draw = function(){
context.beginPath();
context.moveTo(0,0);
context.lineTo(size, 0);
context.stroke();
}
var forward = function(){
context.translate(size, 0);
}
var left = function(){
context.rotate(-angle);
}
var right = function(){
context.rotate(angle);
}
var move = function(goRight){
forward();
if (goRight) {
right();
} else {
left();
}
}
var direction = function(n){
return (((n & -n) << 1) & n) !== 0;
}
var n = 1; var max = Math.pow(2, 15);
var continous = function(){
draw();
move(direction(n++));
requestAnimationFrame(continous);
}
continous();
})(5, Math.PI/2, Math.min, a, c, requestAnimationFrame);