Activate your free membership today | Log-in

Thursday, December 4th, 2008

CanvasTurtle

Category: Canvas, JavaScript

Eiten Suez, author of jMatter, has been up to some fun hacking recently. He just released CanvasTurtle a JavaScript and Canvas version of the old favourite TurtlePascal.

You can build snow flakes with code like this:

JAVASCRIPT:
  1.  
  2. function side(size, level) {
  3.     if (level==0) {
  4.         fd(size);
  5.         return;
  6.     }
  7.     side(size/3, level-1);
  8.     lt(60);
  9.     side(size/3, level-1);
  10.     rt(120);
  11.     side(size/3, level-1);
  12.     lt(60);
  13.     side(size/3, level-1);
  14. }
  15.  
  16. function snowflake(size, level) {
  17.     (3).times(function() {
  18.         side(size, level);
  19.         rt(120);
  20.     });
  21. }
  22.  
  23.  
  24. clean();
  25. lt(30);
  26. setPos(0,-100);
  27. snowflake(250, 4);
  28.  

Or a pretty garden like this.

Posted by Dion Almaer at 6:15 am

+++--
3.9 rating from 15 votes

5 Comments »

Comments feed TrackBack URI

Reminds me of the work by David Jones (drj11) on Curly Logo

Comment by TNO — December 4, 2008

Isn’t TurtlePascal just a copy of the original based on the Logo (Wikipedia). It’s what we used when I was in elementary school on Apple IIGS (or something like that). I’ve been wanting to make a tshirt based on it.

Comment by JonBad — December 4, 2008

Oooh, Eiten branching out towards js? This is an exciting start…

Comment by ilazarte — December 4, 2008

Very interesting whats gonna happen next and how its gonna work out. Meanwhile, ill stand by pictures of tattoo designs and chill

Comment by oldtimerock — March 17, 2009

This is interesting start of something new.
oldtimerock from printable tattoo designs

Comment by oldtimerock — May 27, 2009

Leave a comment

You must be logged in to post a comment.