0

I have found this code for combining polygons into Mosaics. From here it seems that turtle will only go so fast. I don't need the hand drawing and would just like to see the images rendered. Of course, not using turtle, I would have to use something else (I am hoping to use PIL). So the problems are two fold:

  1. How can I still get the up and left movements that seem to draw the mosaic without using Turtle.

  2. How can I use PIL as the image display platform?

It seems however that it is through myPen.left() and myPen.forward() that the drawing happens:

import turtle
myPen = turtle.Turtle()
myPen.shape("arrow")

myPen.speed(1000)
def drawMosaic(color,numberOfSides,size,numberOfIterations):
 myPen.color(color)
 for i in range(0,numberOfIterations):
   for j in range (0,numberOfSides):
     myPen.forward(size)
     myPen.left(360 / numberOfSides)
   myPen.left(360 / numberOfIterations)

drawMosaic("#0B5CCB",8,40,10)
myPen.hideturtle()
cdlane
  • 40,441
  • 5
  • 32
  • 81
Relative0
  • 1,567
  • 4
  • 17
  • 23

1 Answers1

1

I don't need the hand drawing and would just like to see the images rendered.

You can achieve this within turtle. If you don't care about the animation of the drawing process, you can use the tracer() method to turn it off:

from turtle import Screen, Turtle

def drawMosaic(color, numberOfSides, size, numberOfIterations):
    myPen.color(color)

    for _ in range(numberOfIterations):
        for _ in range(numberOfSides):
            myPen.forward(size)
            myPen.left(360 / numberOfSides)

        myPen.left(360 / numberOfIterations)

screen = Screen()

myPen = Turtle(visible=False)

screen.tracer(False)
drawMosaic("#0B5CCB", 8, 40, 10)
screen.tracer(True)

screen.exitonclick()

Make sure to turn tracer() back on after you're done drawing to avoid certain artifacts (like a broken hideturtle(), etc.)

cdlane
  • 40,441
  • 5
  • 32
  • 81