Turtle and drawing tree with RapydScript
<p>today I want draw a tree in browser with RapydScript.
I have code in Python:</p>

<pre><code>import random
import turtle

def tree(size, myTurtle):
    myTurtle.pensize(size / 20)

    if size &lt; random.randint(1,2) * 20:
        myTurtle.color("green")
    else:
        myTurtle.color("brown")

    if size &gt; 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()
</code></pre>

<p>And I want to run it in browser to get this effect:</p>

<p><a href="http://i.stack.imgur.com/NpcHB.png" rel="nofollow"><img src="http://i.stack.imgur.com/NpcHB.png" alt="image"></a>
â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.</p>

<p>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?</p>

<p>As you can see here:
<a href="http://www.transcrypt.org/live/turtle_site/turtle_site.html" rel="nofollow">http://www.transcrypt.org/live/turtle_site/turtle_site.html</a></p>

<p>Transcrypt(similiar tool to RapydScript) somehow can draw with turtle.</p>

<p>Can you help me with this?</p>

<p>Of course I want use Python, I know that RapydScript allows to use JavaScript, but I want Python :))</p>

<p>As @furas mentioned, there is no <code>turtle</code> module in the base repo. First of all, I think you're misunderstanding what the <code>turtle</code> module is, it's nothing more than an abstraction around another graphics library. Even in Python, it's not the preferred way of handling graphics, it's just a subset of Logo toolkit aimed at making programming easier to kids.</p>

<p>With that said, Transcrypt exists in the exact same JavaScript world as RapydScript, the <code>turtle</code> it uses has nothing to do with Python's <code>turtle</code>, it's a wrapper around SVG. In fact, here it is: <a href="https://github.com/JdeH/Transcrypt/blob/master/transcrypt/modules/turtle/__init__.py" rel="nofollow">https://github.com/JdeH/Transcrypt/blob/master/transcrypt/modules/turtle/<strong>init</strong>.py</a></p>

<p>And looking at that code, I can tell you that you can copy-paste it almost verbatim into RapydScript to "gain" a turtle module there. Everything that code does is supported by RapydScript, even the import mechanism between RS and Transcrypt will work the same.</p>

<p>Moreover, a quick Google search revealed 2 JavaScript implementations of this <code>turtle</code> module (which you can just attach to the same page as RapydScript and use them as if they're Python):<br>
<a href="http://berniepope.id.au/html/js-turtle/turtle.html" rel="nofollow">http://berniepope.id.au/html/js-turtle/turtle.html</a><br>
<a href="https://github.com/davebalmer/turtlewax" rel="nofollow">https://github.com/davebalmer/turtlewax</a></p>

<p>Finally, whether or not you use the <code>turtle</code> module doesn't make your code any more or less Python. You also seem to have a misconception that by using a JavaScript library from RapydScript, you need to write the rest of the code in JavaScript. That is not the case, The RapydScript examples directory already shows <a href="https://github.com/atsepkov/RapydScript/tree/master/examples/d3_treemap" rel="nofollow">D3</a>, <a href="https://github.com/atsepkov/RapydScript/tree/master/examples/paint" rel="nofollow">canvas</a>, and <a href="http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/RotatingCubes-RapydScript/edit" rel="nofollow">WebGL</a> examples. The reason there is no turtle module is because it's obsolete compared to the graphics libraries that JavaScript (and RapydScript) has access to. You're welcome to do a pull request with a turtle module implementation, however.</p>

python browser turtle-graphics rapydscript