Javascript Turtle Graphics

Language Reference

forward(distance)
right(angle)
left(angle)
goto(x,y)
clear()
penup()
pendown()
reset()
angle(angle)
width(width)
colour(r,g,b,a)
write(string)
n = random(low,high)
hideTurtle()
showTurtle()
redrawOnMove(bool)
draw()
repeat(n, action)
wrap(bool)
animate(action,ms)
See some other examples

Canvas

Command


Definitions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Define helper functions here.
// For example:
function square(side) {
repeat(4, function () {
forward(side);
right(90);
});
}
function demo() {
hideTurtle();
colour(0,0,255,1);
for(s = 100; s > 0; s -= 10) {
square(s);
right(36);
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX