Draw faster circles with Python turtle

Question:

I have an exercise wherein I have to draw a lot of circles with Python turtle. I have set speed(0) and I am using:

from turtle import*
speed(0)
i=0
while i < 360:
    forward(1)
    left(1)
    i+=1

to draw circles. It takes so long. Is there any faster way?

Asked By: user1794625

||

Answers:

You could draw fewer segments, so rather than 360 you go for 120:

while i < 360:
    forward(3)
    left(3)
    i+=3

That will make your circle less smooth, but three times faster to draw.

Answered By: RichieHindle

The circle() method might not be faster, but may be easier to manage:
turtle.circle()

Answered By: user1908430

Have you tried turtle.delay() or turtle.tracer() ? See documentation here and here. These set options for screen refreshing which is responsible for most of the delays.

Answered By: hola

Use Multithread to draw two semi circles simultaneously.
Initially the turtle will be at (0,0) so just clone the turtle and make them both face in opposite direction by 180° then draw semicircles. The code is below:

from threading import Thread
import turtle
t = turtle.Turtle()
t.speed(0)
def semi1(r):
   r.circle(50,180)
def semi2(t):
   t.circle(50,180)

r = t.clone()
r.rt(180)

a = Thread(target=semi1).start()
b = Thread(target=semi2).start()

This may draw the circle fast.

Answered By: Gokul

Turtle has a function for drawing circles and the speed of that is much faster than going in a circle one step at a time.

 import turtle
 tina=turtle.Turtle()
 
 tina.circle(70)

It will look like this

enter image description here

If you want to draw your circle even faster, you can try adding a delay block as well.

import turtle
tina=turtle.Turtle()

tina.delay(1)
tina.speed(0)
Answered By: Amelie
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.