Python turtle graphics 作例 : とある作図アルゴリズムにおいて変数変化による図の形状一覧

動画




ソースコード


import turtle, math, time
window_x = 16 * 80
window_y = 9 * 80
turtle.setup(window_x, window_y, 0, 300)
turtle.bgcolor("#000000")

llx = 0
lly = 900
urx = 1600
ury = 0
turtle.setworldcoordinates(llx, lly, urx, ury)

def star(x, y, angle, length):
   turtle.pencolor("#FFFFFF")
   turtle.penup()
   turtle.goto(x, y)
   turtle.pendown()
   for i in range(0, 30):
     turtle.fd(length)
     turtle.right(angle)
   turtle.setheading(0)

# turtle.tracer(100,0)
turtle.speed(5)

x_dif = abs(llx - urx)/11
y_dif = abs(lly - ury)/10

h = 1
for m in range(9):
   for n in range(10):
     L = 70
     star((x_dif * n) + (x_dif / 2), (y_dif * m) + (y_dif / 2), 180+h, L)
     h = h + 1

turtle.mainloop()


まとめページ

Python turtle graphics まとめ


スポンサーリンク
Amazon商品リンク : Pythonプログラミング関連

コメント

スポンサーリンク


このブログの人気の投稿

Ubuntu Softwareが起動しないのでいろいろと調べてみる(Ubuntu 20.04.1 LTS)

gnuplotでプロットなどの色をcolornameの指定で変更する

gnuplot : グラフにグリッド線を描く方法(set grid)

gnuplot : プロット画像のサイズ指定について(set sizeとの違い)

Pythonのformat()を使って1桁の16進数でも2桁で出力する方法