-
Notifications
You must be signed in to change notification settings - Fork 0
/
turtle.html
69 lines (67 loc) · 2.04 KB
/
turtle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Javascript Turtle</title>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<link type="text/css" rel="stylesheet" href="turtle.css" />
</head>
<body>
<div id="wrap">
<h1>Javascript Turtle Graphics</h1>
<div id="leftcolumn">
<h4>Language Reference</h4>
<code>
forward(distance) <br/>
right(angle) <br/>
left(angle) <br/>
goto(x,y) <br/>
clear() <br/>
penup() <br/>
pendown() <br/>
reset() <br/>
angle(angle) <br/>
width(width) <br/>
colour(r,g,b,a) <br/>
write(string) <br/>
n = random(low,high) <br/>
hideTurtle() <br/>
showTurtle() <br/>
redrawOnMove(bool) <br/>
draw() <br/>
repeat(n, action) <br/>
wrap(bool) <br/>
animate(action,ms) <br/>
</code>
</div> <!-- leftcolumn -->
<div id="midcolumn">
<h4>Canvas</h4>
<canvas id="turtlecanvas" width="300" height="300"></canvas>
<canvas id="imagecanvas" width="300" height="300" style="display:none"></canvas>
<h4>Command</h4>
<input type="text" id="command" />
</div> <!-- midcolumn -->
<div id="rightcolumn">
<h4>Definitions</h4>
<textarea id="definitions" rows="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);
}
}
</textarea>
</div> <!-- rightcolumn -->
</div> <!-- wrap-->
<script type="text/javascript" src="turtle.js"></script>
</body>
</html>