turtle モジュールをimportするには
Tkinterをインストールします。
$ sudo apt-get install python-tk
turtle の形は次の5種類から選べます。
"arrow", "turtle", "circle", "square", "triangle", "classic"
turtle.shape("turtle")
と指定すれば文字どおり亀になります。
'blank'を指定することもできます。
また任意のGif画像を指定することもできます。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from turtle import * | |
def yen(t,x,y,s) : | |
t.penup() | |
t.setx (x) | |
t.sety (y-s) | |
t.pendown() | |
t.circle(s) | |
t=Turtle() | |
s=t.getscreen() | |
s.register_shape("a.gif") | |
t.shape('a.gif') | |
yen(t,0,0,100) | |
done() |

(注:「カメ」のように向きを変えながら描画はできない。)
0 件のコメント:
コメントを投稿