Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5724a1

Browse files
Add files via upload
1 parent 6043b7c commit c5724a1

File tree

2 files changed

+249
-0
lines changed

2 files changed

+249
-0
lines changed

‎Butterfly.py

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
import turtle as tur
2+
3+
tur.title("Snake coding - Butterfly")
4+
tur.width(2)
5+
tur.speed(10)
6+
7+
color1 = "#f6aa0c"
8+
color2 = "#0099ff"
9+
color3 = "#f83079"
10+
color4 = "#72e7fb"
11+
12+
def go_to(pos):
13+
tur.speed(0)
14+
tur.up()
15+
tur.goto(pos[0], pos[1])
16+
tur.down()
17+
tur.speed(10)
18+
19+
def rel_pos(x,y):
20+
tur.speed(0)
21+
tur.up()
22+
tur.goto(tur.pos()+(x,y))
23+
tur.down()
24+
tur.speed(10)
25+
26+
def draw_oval(width, height, color):
27+
tur.speed(0)
28+
tur.fillcolor(color)
29+
tur.begin_fill()
30+
for _ in range(2):
31+
tur.circle(height/2, 45)
32+
tur.circle(width/2, 135)
33+
tur.end_fill()
34+
tur.speed(10)
35+
36+
def draw_heart(size):
37+
tur.left(50)
38+
tur.forward(size)
39+
tur.circle(size * 0.5, 200)
40+
tur.right(140)
41+
tur.circle(size * 0.5, 200)
42+
tur.forward(size+5)
43+
tur.left(50)
44+
45+
def rightwings(top_pos):
46+
go_to(top_pos)
47+
tur.seth(-65)
48+
tur.circle(-200,35)
49+
cur_pos = tur.pos()
50+
tur.begin_fill()
51+
tur.fillcolor(color1)
52+
draw_heart(100)
53+
tur.end_fill()
54+
go_to((cur_pos[0],cur_pos[1] + 20))
55+
tur.begin_fill()
56+
tur.fillcolor(color2)
57+
draw_heart(80)
58+
tur.end_fill()
59+
60+
rel_pos(60,-70)
61+
tur.seth(-45)
62+
draw_oval(20,50,color3)
63+
rel_pos(-25,30)
64+
draw_oval(10, 30, color3)
65+
rel_pos(-10, -15)
66+
draw_oval(10,20,color4)
67+
68+
go_to(top_pos)
69+
tur.seth(-65)
70+
tur.circle(-200,20)
71+
cur_pos = tur.pos()
72+
tur.begin_fill()
73+
tur.fillcolor(color1)
74+
draw_heart(100)
75+
tur.end_fill()
76+
go_to(cur_pos)
77+
tur.begin_fill()
78+
tur.fillcolor(color2)
79+
draw_heart(80)
80+
tur.end_fill()
81+
82+
rel_pos(50,30)
83+
tur.seth(10)
84+
draw_oval(10,60,color3)
85+
rel_pos(40,-5)
86+
draw_oval(20,60,color4)
87+
rel_pos(-10,-40)
88+
draw_oval(20,40,color3)
89+
tur.seth(-45)
90+
rel_pos(0,-45)
91+
draw_oval(10,80,color4)
92+
rel_pos(-30,20)
93+
draw_oval(10,30,color4)
94+
rel_pos(-30,30)
95+
draw_oval(25,30,color3)
96+
97+
def leftWings(top_pos):
98+
go_to(top_pos)
99+
tur.seth(-110)
100+
tur.circle(200,22)
101+
cur_pos = tur.pos()
102+
tur.seth(100)
103+
tur.begin_fill()
104+
tur.fillcolor(color1)
105+
draw_heart(100)
106+
tur.end_fill()
107+
go_to((cur_pos[0], cur_pos[1] + 10))
108+
tur.begin_fill()
109+
tur.fillcolor(color2)
110+
draw_heart(80)
111+
tur.end_fill()
112+
113+
rel_pos(-80, -45)
114+
tur.seth(-135)
115+
draw_oval(20, 50, color3)
116+
rel_pos(25,30)
117+
draw_oval(10,30,color4)
118+
rel_pos(30,10)
119+
draw_oval(10,20,color3)
120+
121+
go_to(top_pos)
122+
tur.seth(-110)
123+
tur.circle(200,5)
124+
cur_pos = tur.pos()
125+
tur.seth(90)
126+
tur.begin_fill()
127+
tur.fillcolor(color1)
128+
draw_heart(100)
129+
tur.end_fill()
130+
go_to((cur_pos[0], cur_pos[1] -15))
131+
tur.begin_fill()
132+
tur.fillcolor(color2)
133+
draw_heart(80)
134+
tur.end_fill()
135+
136+
rel_pos(-90,50)
137+
tur.seth(110)
138+
draw_oval(10,60,color4)
139+
rel_pos(40,-5)
140+
draw_oval(20,60,color4)
141+
rel_pos(-10,-40)
142+
draw_oval(20,40,color3)
143+
tur.seth(-150)
144+
rel_pos(-29,-30)
145+
draw_oval(10,80,color4)
146+
rel_pos(-30,20)
147+
draw_oval(10,30, color3)
148+
rel_pos(90,15)
149+
draw_oval(10,30,color3)
150+
151+
def drawWings(top_pos):
152+
rightwings(top_pos)
153+
leftWings(top_pos)
154+
155+
def drawButterfly():
156+
tur.seth(70)
157+
tur.circle(200,45)
158+
top_pos = tur.pos()
159+
tur.seth(-110)
160+
tur.circle(200,45)
161+
go_to(top_pos)
162+
tur.seth(0)
163+
tur.begin_fill()
164+
tur.fillcolor(color2)
165+
tur.circle(10)
166+
tur.end_fill()
167+
tur.circle(10, 180)
168+
tur.width(3)
169+
cur_pos = tur.pos()
170+
tur.seth(90)
171+
tur.circle(50,60)
172+
go_to(cur_pos)
173+
tur.seth(90)
174+
tur.circle(-50,60)
175+
tur.width(2)
176+
177+
drawWings(top_pos)
178+
go_to((0,0))
179+
tur.begin_fill()
180+
tur.fillcolor(color1)
181+
tur.seth(70)
182+
tur.circle(200,45)
183+
top_pos = tur.pos()
184+
tur.seth(-110)
185+
tur.circle(200,45)
186+
tur.end_fill()
187+
188+
tur.begin_fill()
189+
tur.fillcolor(color3)
190+
tur.seth(70)
191+
tur.circle(200,20)
192+
tur.seth(180)
193+
tur.forward(30)
194+
tur.seth(-85)
195+
tur.circle(200,20)
196+
tur.end_fill()
197+
198+
tur.begin_fill()
199+
tur.fillcolor(color1)
200+
tur.seth(70)
201+
tur.circle(200,15)
202+
tur.seth(180)
203+
tur.forward(27)
204+
tur.seth(-81)
205+
tur.circle(200,15)
206+
tur.end_fill()
207+
208+
go_to((0,0))
209+
tur.begin_fill()
210+
tur.fillcolor(color4)
211+
tur.seth(70)
212+
tur.circle(200, 10)
213+
tur.seth(180)
214+
tur.forward(20)
215+
tur.seth(-75)
216+
tur.circle(200,10)
217+
tur.end_fill()
218+
219+
drawButterfly()
220+
go_to((-180, -200))
221+
tur.write("""Snake coding \n please subscribe!""",
222+
font=('Arial',40,'bold'))
223+
tur.done()
224+
225+
226+
227+
228+
229+
230+
231+
232+
233+
234+
235+
236+
237+
238+
239+
240+
241+
242+
243+
244+
245+
246+
247+
248+
249+

‎Screenshot.png

205 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /