Created
October 2, 2017 17:38
-
-
Save ulrichzwingli/0c29b15f358b9246123446bb44db79f8 to your computer and use it in GitHub Desktop.
Exploring Turtle : Random images
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
from turtle import * | |
import random | |
colors = ['orange', 'yellow', 'red', 'green', 'blue','cyan'] | |
for n in range(50): | |
penup() | |
goto(random.randint(-400, 400), random.randint(-400, 400)) | |
pendown() | |
distance = random.randint(10, 40) | |
pensize(random.randint(1, 5)) | |
for i in range(n+5): | |
fillcolor(colors[i % 6]) | |
begin_fill() | |
forward(distance) | |
setheading(i) | |
forward(n*5) | |
goto(0,0) | |
end_fill() | |
penup() | |
goto(random.randint(-400, 400), random.randint(-400, 400)) | |
pendown() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment