Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2013, 11:00 PM   PM User | #1
katrina123
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
katrina123 is an unknown quantity at this point
How to do a twindragon fractal in javascript

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);
}
katrina123 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:56 AM.


Advertisement
Log in to turn off these ads.