@Charanpreet/

Project 5 - Picture

Python (with Turtle)

No description

fork
loading
main.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import turtle
turtle.hideturtle()
def draw_star(size):
  count = 0
  angle = 144
  while count <= 4:
      turtle.forward(size)
      turtle.right(angle)
      count += 1
  return
turtle.speed(0)
def draw_regular_hexagon(side_length):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor()
  turtle.setheading(0)
  turtle.pendown()
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.penup()
def draw_rectangle(width, height):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor()
  turtle.setheading(0)
  turtle.pendown()
  turtle.forward(width)
  turtle.left(90)
  turtle.forward(height)
  turtle.left(90)
  turtle.forward(width)
  turtle.left(90)
  turtle.forward(height)
  turtle.penup()
def draw_column_of_stars(num_stars, stars_size):
  turtle.pendown()
  starting_y = turtle.ycor()
  for _ in range(num_stars):
    draw_star(stars_size)
    turtle.sety(turtle.ycor() + stars_size)
  turtle.sety(starting_y)
  turtle.penup()
def draw_a_row_of_stars(num_stars, stars_size):
  turtle.pendown()
  starting_x = turtle.xcor()
  for _ in range(num_stars):
    draw_star(stars_size)
    turtle.setx(turtle.xcor() + stars_size)
  turtle.setx(starting_x)
  turtle.penup()
def draw_equilateral_triangle(side_length):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor ()
  turtle.setheading(90)
  turtle.pendown()
  turtle.forward(side_length)
  turtle.left(120)
  turtle.forward(side_length)
  turtle.left(120)
  turtle.forward(side_length)
  turtle.penup()
turtle.penup()
turtle.goto(-300, -200)
turtle.color('gold')
draw_a_row_of_stars(60,10)
turtle.penup()
turtle.goto(-300, 200)
draw_a_row_of_stars(60,10)
turtle.penup()
turtle.goto(-300, -200)
draw_column_of_stars(41,10)
turtle.penup()
turtle.goto(300, -200)
draw_column_of_stars(41,10)
turtle.penup()
turtle.goto(-110,50)
turtle.color('maroon')
turtle.begin_fill()
draw_rectangle(200,105)
turtle.end_fill()
turtle.penup()
turtle.goto(-170, 50)
turtle.pensize(0)
turtle.color('green')
turtle.begin_fill()
draw_regular_hexagon(60.7)
turtle.end_fill()
turtle.color('orange')
turtle.goto(-110,-50)
turtle.begin_fill()
draw_rectangle(10,100)
turtle.end_fill()
turtle.goto(-90,-50)
turtle.begin_fill()
draw_rectangle(10,100)
turtle.end_fill()
turtle.goto(80,-50)
turtle.begin_fill()
draw_rectangle(10,100)
turtle.end_fill()
turtle.goto(60,-50)
turtle.begin_fill()
draw_rectangle(10,100)
turtle.end_fill()
turtle.goto(-110,-50)
turtle.right(90)
draw_equilateral_triangle(10)
turtle.goto(-90,-50)
turtle.right(90)
draw_equilateral_triangle(10)
turtle.goto(80,-50)
turtle.right(90)
draw_equilateral_triangle(10)
turtle.goto(60,-50)
turtle.right(90)
draw_equilateral_triangle(10)
turtle.penup()
turtle.goto(90,150)
turtle.setheading(0)
turtle.pendown()
turtle.begin_fill()
turtle.forward(70)
turtle.setheading(-90)
turtle.forward(70)
turtle.setheading(0)
turtle.forward(20)
turtle.setheading(-90)
turtle.forward(10)
turtle.setheading(180)
turtle.forward(30)
turtle.setheading(90)
turtle.forward(70)
turtle.setheading(180)
turtle.forward(60)
turtle.end_fill()
turtle.penup()
turtle.goto(-160,130)
turtle.setheading(0)
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(-120,130)
turtle.setheading(0)
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.goto(150,-30)
turtle.left(180)
turtle.pendown()
for i in range(360):
  turtle.forward(.1)
  turtle.left(1)
turtle.left(90)
turtle.forward(115)
result
console