python

タートルによるお絵描き

turtle(タートル)を利用すると、お絵描きができます。

タートルによる簡単なお絵描き

turtleを使って簡単なお絵描きを行います。
# タートルをインポート
import turtle

# 画面設定
screen=turtle.Screen() #スクリーンを取得
screen.setup(1200,800) #スクリーンのサイズを設定

# タートル設定
turtle=turtle.Turtle() #タートル生成
turtle.shape("turtle") #タートルの形状を設定
turtle.pensize(5)
turtle.pencolor("red")

# タートル描画
#turtle.pendown() #ペンを下す(無くても可/デフォルトではペンは下がっている)
turtle.forward(200)
turtle.left(90)
turtle.forward(100)

screen.mainloop()
タートルによる絵が表示されます。
turtle_image