forked from skulpt/skulpt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathturtle.html
45 lines (37 loc) · 1.16 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
<html>
<head>
<script src="../dist/skulpt.min.js" type="text/javascript"></script>
<script src="../dist/skulpt-stdlib.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
</head>
<body>
<div id="mycanvas" height="500" width="800"
style="border-style: solid;"></div>
<textarea id="code" rows="24" cols="80">
import turtle
wn = turtle.Screen()
babbage = turtle.Turtle()
babbage.shape("triangle")
n = 8
angle = 360/n
for i in range(n):
babbage.right(angle)
babbage.forward(90)
babbage.stamp()
wn.exitonclick()
</textarea>
<script>
var prog = document.getElementById("code").value;
function builtinRead(x) {
if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)
throw "File not found: '" + x + "'";
return Sk.builtinFiles["files"][x];
}
(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';
Sk.configure({ read: builtinRead });
Sk.misceval.asyncToPromise(function() {
return Sk.importMainWithBody("<stdin>",false,prog,true);
});
</script>
</body>
</html>