-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2_star.py
More file actions
executable file
·50 lines (38 loc) · 730 Bytes
/
Copy path2_star.py
File metadata and controls
executable file
·50 lines (38 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# -*- coding: utf-8 -*- #
"""
Draw stuff
"""
from turtle import *
import random
def draw_star(x=0, y=0):
'''
Draw a star
'''
penup()
setpos(x, y)
endx, endy = pos()
pendown()
color('red', 'yellow')
while True:
forward(100)
left(170)
if distance(endx, endy) < 1:
break
def draw_stars(nb=2):
'''
Draw a bunch of stars
'''
r = random.Random()
for i in range(nb):
begin_fill()
x = r.randint(-200, 200)
y = r.randint(-200, 200)
draw_star(x, y)
end_fill()
done()
def say_bye(x, y):
bye()
if __name__ == '__main__':
onclick(say_bye)
draw_stars(2)