Faster drawing in python

I got a program that draws a spaceship (Tortoise graphics) forward, backward, etc.

Using lots of orders and blueprints, the spaceship takes 5 seconds using turtle.speed (0).

And whenever you press the right / left key, it draws it again in the other direction. This is the main thing in my project. Is there a way to make it faster? Thank you in advance.

+3


source to share


2 answers


It turtle

has a pull-in delay of 10 milliseconds by default . Every time it refreshes the canvas, it pauses for 10 milliseconds as an easy way to control the animation speed. This delay is independent of the speed of the turtle itself. If you want to speed up the animation, you can set a shorter delay, for example. with turtle.delay(3)

or turtle.delay(0)

.



Note that turtle graphics are more of an educational tool than a serious way to make graphics. If you don't have a specific reason to use turtle

, consider switching to other graphics libraries.

+2


source


you can use screen.tracer(n)

where higher value n

means faster drawing speed but less detail



+1


source







All Articles