Python turtle graphics 作例 : 複数のチェック柄の円
動画
完成図(静止画)
ソースコード
import turtle
turtle.setup(960,720,None,None)
t1 = turtle.Turtle()
t2 = turtle.Turtle()
t3 = turtle.Turtle()
t4 = turtle.Turtle()
t5 = turtle.Turtle()
t6 = turtle.Turtle()
myturtles = [t1, t2, t3, t4, t5, t6]
mycolor = ["red", "orange", "cyan", "green", "blue", "gray"]
myr = [36, 30, 24, 18, 12, 6]
myradius = [50,50,50,50,50,50]
mygoto = [(-300,150), (0,150), (300,150), (-300,-150), (0,-150), (300,-150)]
turtle.tracer(10,3)
for cnt, num in enumerate(myturtles):
num.speed(10)
num.goto(mygoto[cnt])
num.clear()
r_n = min(myr)
for i in range(0, 360//r_n):
for cnt, num in enumerate(myturtles):
if 360 > myr[cnt] * i:
num.left(myr[cnt])
num.circle(myradius[cnt], steps=100)
else :
continue
turtle.tracer(1000,0)
for cnt, num in enumerate(myturtles):
num.hideturtle()
num.speed(0)
num.fillcolor(mycolor[cnt])
num.clear()
num.begin_fill()
for i in range(0, 360//myr[cnt]):
num.left(myr[cnt])
num.circle(myradius[cnt], steps=100)
num.end_fill()
turtle.mainloop()
まとめページ
Python turtle graphics まとめスポンサーリンク
Amazon商品リンク : Pythonプログラミング関連
コメント
コメントを投稿