simpleskulpt.html for processing instead of turtle

57 views
Skip to first unread message

Rex Allison

unread,
Oct 25, 2016, 2:19:11 PM10/25/16
to Skulpt
Has anyone created a version of simpleskulpt.html that uses the processing module instead of the turtle module? I don't know enough about the inner workings of skulpt and javascript to figure this out.
Thanks.

Michael Cimino

unread,
Oct 25, 2016, 10:47:27 PM10/25/16
to Skulpt
I haven't seen what you're asking for, but you could try looking at the source code for http://www.skulpt.org/static/proctest.html which has 2 examples using the processing module.

Rex Allison

unread,
Oct 25, 2016, 11:26:14 PM10/25/16
to Skulpt
I was thinking along these same lines. I made a local copy and tried running it in firefox. The run button doesn't produce an output. The page is huge

My first approach was to try to run a simple python processing script in simpleskulpt.html:


from processing import *

def setup():
    size
(400,400)
    noStroke
()
    smooth
()
    noLoop
()

def draw():
    rect
(200,170,6,6)


run
()

I was thinking that this is the line in simpleskulpt.html that needs to be changed for processing vs turtle:

(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';

This is just a guess at this point.

Rex Allison

unread,
Oct 25, 2016, 11:30:45 PM10/25/16
to Skulpt
Oops. Didn't mean to say the page is huge, it is actually quite reasonable in size. I need to check my edits before submitting.


Rex Allison

unread,
Oct 27, 2016, 9:26:31 PM10/27/16
to Skulpt
I finally got a solution working with three changes to  simpleskulpt.html.

Add after line 5
<script src="http://www.skulpt.org/static/python.min.js" type="text/javascript"></script>
<script src="http://www.skulpt.org/static/processing-1.4.1.min.js" type="text/javascript"></script>

Change

(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';
to
Sk.canvas = 'mycanvas';

Change
import turtle
       
t = turtle.Turtle()
       
t.forward(100)

print "Hello World"

to your processing python code, example here
from processing import *

def setup():

    size
(640,416)
simpleskulpt_processing_changes.html
Reply all
Reply to author
Forward
0 new messages