pythonturtle-graphicspython-turtle

Save image with Python Turtle Graphics?


I have been trying to create and export an image with python turtle graphics, and I am using turtle.getscreen().getcanvas().postscript(name="foo.esp") to export it (found here). When I call turtle.getscreen(), then the turtle shows up on the screen, and doesn't hide, even when I call the turtle's hideturtle() method.

I tried to delete the turtle using del, but the turtle stayed on screen. I tried calling the turtle's reset method, but that cleared everything it drew. I tried moving it off the screen, but upon calling turtle.getscreen(), it just moved back to the center of the screen.


Solution

  • I figured out how to get the image, but it was kind of complicated. After exporting the image as a .eps file, I opened the file with an editor. Since a .eps file is not binary, I was able to remove the part that draws the turtle, which is located at the bottom of the .eps file, above "grestore" and below "x y z setrgbcolor AdjustColor", where x, y and z are all floats with 3 digits of precision.

    A picture showing what to be deleted