Saving output of Turtle Graphics?

Wojciech Muła wojciech_mula at poczta.null.onet.pl.invalid
Sat Apr 7 11:48:51 EDT 2007


Dick Moores wrote:
>> Turtle module uses Tk canvas element to draw graphics ('_canvas'
>> attribute). I've written module, that exports canvas graphics to SVG
>> file: http://wmula.republika.pl/proj/canvas2svg/ -- it may be useful
>> for you.
> 
> I afraid I'm totally unfamiliar with SVG. Would it be possible for you
> or someone else on the list to show how to use your module to export the 
> simple product of this simple script to an SVG file?
> 
> ===============================================
> import turtle as T
import canvasvg
> from random import randint
> T.setup(width=1000, height=700, startx=0, starty=0)
> T.color(1, .5, .5)
> T.begin_fill()
> # 2 connected lines will fill as a triangle
> for x in range(2):
>     coord = (randint(-500,500), randint(-350,350))
>     T.goto(coord)
> T.end_fill()

canvasvg.saveall("image.svg", T._canvas)

> T.done()
> ================================================

w.



More information about the Python-list mailing list