This week I built the first release of PicoTurtle - a turtle program built on REST/HTTP APIs, allowing programs written in potentially any programming language to draw turtle graphics with it. The desktop editor is built using electron. Download it at PicoTurtle Homepage.
I'll make follow-up posts about how the program works, but here's a dragon curve drawn using picoturtle...
And here's the code... (based on the entry on dragon curve in wikipedia at https://en.wikipedia.org/wiki/Dragon_curve#Code)
from picoturtle import *
create_turtle()
### Your code goes here ###
def dragonCurve(order, length):
right(order * 45)
dragonCurveRecursive(order, length, 1)
def dragonCurveRecursive(order, length, sign):
if order == 0:
forward(length)
else:
rootHalf = (1 / 2) ** (1 / 2)
dragonCurveRecursive(order - 1, length * rootHalf, 1)
right(sign * -90)
dragonCurveRecursive(order - 1, length * rootHalf, -1)
pencolour(255, 0, 0)
penwidth(1.5)
back(150)
pendown()
dragonCurve(11, 300)
### Your code ends here ###
### Always stop the turtle
stop()