Created
July 16, 2020 10:26
-
-
Save umcconnell/fcb00ff25acf101b72d4e67f0b4ff12f to your computer and use it in GitHub Desktop.
Spiralling shapes with Python turtle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
turtle.speed(0) | |
def spiralling_shape(sides: int = 4, iterations: int = 200, scale: int = 1): | |
for i in range(iterations): | |
turtle.forward(i*scale) | |
turtle.left(360//sides + 1) | |
# Make a spiralling square | |
spiralling_shape() | |
# Or a spiralling triangle scaled by factor 3 | |
spiralling_shape(sides=3, scale=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment