html
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
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.rawgit.com/skulpt/skulpt-dist/0.11.0/skulpt.min.js"></script>
<script src="https://cdn.rawgit.com/skulpt/skulpt-dist/0.11.0/skulpt-stdlib.js"></script>
</head>
<body>
<center>
<h3>Powered by Skulpt<a href="http://www.skulpt.org">Skulpt</a></h3></center>
<!-- code actually came from stackoverflow - touch the canvas background and the pointer will follow to the touched position -->
<!-- https://stackoverflow.com/questions/20035132/python-using-turtle-button -->
<textarea id="code" cols="40" rows="20">
import turtle as t
from random import randint
print("Touch the canvas in various spots \nor multiple touch and create interesting designs")
class Turtle(t.Turtle) :
def __init__(self,**args) :
t.Turtle.__init__(self,**args)
def mygoto(self,x,y) :
t1.goto(x,y)
print x,y
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
body {
background-color: blue;
color: yellow;
width:340px;
}
#code {
display: none;
}
#mycanvas{
background-color: lightblue;
}
Enter to Rename, Shift+Enter to Preview
js
js
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
function outf(text) {
var mypre = document.getElementById("output");
mypre.innerHTML = mypre.innerHTML + text;
}
function builtinRead(x) {
if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)
throw "File not found: '" + x + "'";
return Sk.builtinFiles["files"][x];
}
function runit() {
var prog = document.getElementById("code").value;
var mypre = document.getElementById("output");
mypre.innerHTML = '';
Sk.pre = "output";
Sk.configure({output:outf, read:builtinRead});
(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';
var myPromise = Sk.misceval.asyncToPromise(function() {
return Sk.importMainWithBody("<stdin>", false, prog, true);
});
myPromise.then(function(mod) {
//Worked
},
function(err) {
console.log(err.toString());
});
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run