Using the Python Imaging Library I’ve created a faster alternative to the turtle.py module. It takes only a few seconds to draw images that were taking several minutes with turtle.py.
There are a few downsides to this approach I suppose:
- There is no on-screen animation of the image being created which is useful tool when teaching turtle graphics — only a finished image is created.
- Output is a raster image, not a nice svg or eps file.
On the up side:
- Super fast
- All Python Imaging Library tools and methods also available.
- At the moment is largely compatible with the turtle.py module
Who knows… once I’ve got the code into a more finished state I may share my fast-turtle module with the world.
Here’s a nice animation that I created with my aforementioned fast turtle module:
Python comes with a turtle graphics module right there in the standard library. A new and improved version was introduced with Python 2.6, and it is quite good. I think its real strength could be in the initial stages of teaching kids to program in Python.
For my use I found two major drawbacks. First, there is no built-in way to export your drawing to an image file (taking a screenshot is the solution I’ve been using). More importantly, the turtle drawing is intolerable slow for complex images.
I did manage to create this rather nice recursive tree:
(The leaves are dead turtles)
Nevertheless I think I will concentrate on some other turtle graphics implementation for now. After all, I already program in Python so I won’t be learning anything new there. Also did I mention slow? So slow.
I would be interested in learning UCBLogo as the language itself would be interesting for me to learn (A far more turtle-y Lisp dialect). Also from my initial tests it seems to be so much faster than turtle.py. However it also has limited capacity to save drawings as images (only eps output with no filled shapes 😦 ). The output window also appears buggy on my Ubuntu Linux system… The image in the window does not refresh after being obscured or minimised, which pretty much makes it useless to me until this issue has been addressed. I figured out that turning on window compositing fixes this somewhat. The output is no longer deleted after the output window is obscured by another window. If you minimise or resize the window the image disappears, but seems to come back most of the time if you type “REFRESH” into the Logo session.