...

View Full Version : How to do a twindragon fractal in javascript



katrina123
02-01-2013, 11:00 PM
Hi every body :) !
I want to code for a fractal Twindragon in Javascript, but I don't know how to do...Cam you help me please ?

var n = 8;
var l = 5;
var angle = 120 * Math.PI / 180;

c.translate(300, 200);
twindragon(n);
function twindragon(n) {
if (n <= 1) {
drawLine(l);
} else {
twindragon(n-1);
c.rotate(angle);
twindragon(n-1);
c.rotate(-angle);
twindragon(n-1);
}
}
function drawLine(l) {
c.beginPath();
c.moveTo(0, 0);
c.lineTo(l, 0);
c.stroke();
c.translate(l, 0);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum