-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogo.html
More file actions
38 lines (38 loc) · 1.18 KB
/
Copy pathlogo.html
File metadata and controls
38 lines (38 loc) · 1.18 KB
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
<html>
<head>
<title> Logo demo </title>
<script src="logo.js"></script>
</head>
<body>
<div id="iconsole">
<div id="prev"></div>
<input id="prompt"/>
<button id="evaluate">Evaluate</button>
</div>
<canvas id="main-canvas"></canvas>
<script>
function $(id) {
return document.getElementById(id);
}
var can = $('main-canvas'),
ctx = can.getContext('2d');
can.width = 800;
can.height = 600;
var turtle = new Turtle(drawCback(ctx, new Bounds(800, 600)));
turtle.state.x = 400;
turtle.state.y = 300;
$('prompt').onkeypress = function(e) {
if(e.keyCode === 13) {
$('evaluate').click();
}
};
$('evaluate').onclick = function() {
var txt = $('prompt').value,
cmd = parseLogoCmd(txt);
turtle.apply(cmd);
$('prev').innerHTML += '<br/>' + txt;
$('prompt').value = '';
};
</script>
</body>
</html>