• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# randomly generated spirals with turtle graphics

ziyadzer Sep 23rd, 2019 79 in 339 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import turtle
2. import random
3.
4. #Creating the turtles
5. random1 = turtle.Turtle()
6.
7. #Hiding the turtles
8. random1.ht()
9.
10. #Creating the hex conversion list
11. hexlist = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]
12.
13. #Drawing lines
14. for drawnum in range(5):
15.   #Randomly selecting the angle, distance, color, and number of repeats for random1
16.   a1 = random.randint(-359,359)
17.   d1 = random.randint(1,300)
18.   n1 = random.randint(1,360)
19.   c1 = "#"
20.   for i in range(6):
21.     j = random.randint(0,15)
22.     c1 += hexlist[j]
23.   #-------#
24.   a1a = random.randint(-359,359)
25.   d1a = random.randint(1,300)
26.   c1a = "#"
27.   for i in range(6):
28.     j = random.randint(0,15)
29.     c1a += hexlist[j]
30.   #-------#
31.   a1b = random.randint(-359,359)
32.   d1b = random.randint(1,300)
33.   c1b = "#"
34.   for i in range(6):
35.     j = random.randint(0,15)
36.     c1b += hexlist[j]
37.
38.   #Drawing random1
39.   random1.speed(0)
40.   for x in range(n1):
41.     #Line segment 1
42.     random1.color(c1)
43.     random1.fd(d1)
44.     #Line segment 2
45.     random1.color(c1a)
46.     random1.lt(a1a)
47.     random1.fd(d1a)
48.     #Line segment 3
49.     random1.color(c1b)
50.     random1.lt(a1b)
51.     random1.fd(d1b)
52.     #Going to the next position
53.     random1.up()
54.     random1.goto(0,0)
55.     random1.rt(a1a)
56.     random1.rt(a1b)
57.     random1.lt(a1)
58.     random1.down()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top