today I want draw a tree in browser with RapydScript. I have code in Python:
import random
import turtle
def tree(size, myTurtle):
myTurtle.pensize(size / 20)
if size < random.randint(1,2) * 20:
myTurtle.color("green")
else:
myTurtle.color("brown")
if size > 5:
myTurtle.forward(size)
myTurtle.left(25)
tree(size - random.randint(10, 20), myTurtle)
myTurtle.right(50)
tree(size - random.randint(10, 20), myTurtle)
myTurtle.left(25)
myTurtle.penup()
myTurtle.backward(size)
myTurtle.pendown()
window = turtle.Screen()
window.setup(800,600)
window.bgcolor("white")
myTurtle = turtle.Turtle()
myTurtle.color("brown", "blue")
myTurtle.left(90)
myTurtle.speed(0)
myTurtle.penup()
myTurtle.setpos(0, -250)
myTurtle.pendown()
And I want to run it in browser to get this effect:
Don't worry about text over the tree, is in polish ;) I run this in Skulpt, maybe you hear about it, effect you have above. Now I want to run this in RapydScript and compare it to Skulpt and Brython.
I am wonder if it possible in RapydScript beacuse this code use turtle module. I guess that I need to change this code somehow to run it on RapydScript. Did RapydScript allow to import turtle module?
As you can see here: http://www.transcrypt.org/live/turtle_site/turtle_site.html
Transcrypt(similiar tool to RapydScript) somehow can draw with turtle.
Can you help me with this?
Of course I want use Python, I know that RapydScript allows to use JavaScript, but I want Python :))
See src/lib
in RapydScript repo - there is no turtle
module. And it can't import turtle module from Python because it doesn't draw on canvas in browser. So you can't draw tree if you doesn't create turtle module.