app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import turtle from PIL import Image # Setup turtle screen screen = turtle.Screen() screen.setup(width=800, height=800) screen.bgcolor("white") # Create turtle t = turtle.Turtle() t.speed(0) r = 10 # radius # Draw concentric circles for i in range(1, 50): t.circle(r * i) t.up() t.sety((r * i) * (-1)) t.down() # Save as PostScript ts = t.getscreen() ts.getcanvas().postscript(file="drawing.eps") # Convert to PNG using PIL img = Image.open("drawing.eps") img.save("drawing.png", "png") print("Image saved as drawing.png") # Optional: Close turtle graphics window turtle.done() |