-
Notifications
You must be signed in to change notification settings - Fork 38
/
house.py
79 lines (68 loc) · 1.26 KB
/
house.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import turtle
t = turtle.Turtle()
t.speed(0)
turtle.bgcolor("skyblue")
def draw_rectangle(width, height, color):
t.fillcolor(color)
t.begin_fill()
for _ in range(2):
t.forward(width)
t.left(90)
t.forward(height)
t.left(90)
t.end_fill()
def draw_triangle(size, color):
t.fillcolor(color)
t.begin_fill()
for _ in range(3):
t.forward(size)
t.left(120)
t.end_fill()
# house
t.penup()
t.goto(-100, -100)
t.pendown()
draw_rectangle(200, 150, "beige")
# roof
t.penup()
t.goto(-110, 50)
t.pendown()
draw_triangle(220, "red")
# door
t.penup()
t.goto(-30, -100)
t.pendown()
draw_rectangle(60, 100, "brown")
# doorknob
t.penup()
t.goto(15, -60)
t.pendown()
t.fillcolor("gold")
t.begin_fill()
t.circle(5)
t.end_fill()
# left window
t.penup()
t.goto(-75, 0)
t.pendown()
draw_rectangle(40, 40, "lightblue")
# right window
t.penup()
t.goto(35, 0)
t.pendown()
draw_rectangle(40, 40, "lightblue")
def draw_window_panes(x, y):
t.penup()
t.goto(x, y)
t.pendown()
t.setheading(0)
t.forward(40)
t.penup()
t.goto(x + 20, y + 20) # bars of the window
t.pendown()
t.setheading(270)
t.forward(40)
draw_window_panes(-75, 20)
draw_window_panes(35, 20)
t.hideturtle()
turtle.done()