import turtle as t
#定位
def my_goto(x,y):
t。up()
t。goto(x,y)
t。down()
#眼睛
def eyes():
t。tracer(False)
a = 2。5
for i in range(120):
if 0
a -= 0。05
t。lt(3)
t。fd(a)
else:
a += 0。05
t。lt(3)
t。fd(a)
t。tracer(True)
#鬍鬚
def beard(x,y,s,f):
my_goto(x, y)
t。seth(s)
t。fd(f)
#畫手
def hand(s,color,c):
t。seth(s)
t。fillcolor(color)
t。begin_fill()
t。circle(c)
t。end_fill()
#畫腳
def foot(x,y,s,color,f1,c1,c2,f2,c3,c4,f4):
my_goto(x, y)
t。seth(s)
t。fillcolor(color)
t。begin_fill()
t。fd(f1)
t。circle(c1, c2)
t。fd(f2)
t。circle(c3, c4)
t。fd(f4)
t。end_fill()
#頭
t。pensize(3)
t。up()
t。circle(150,40)
t。down()
t。fillcolor(“#007fff”)
t。begin_fill()
t。circle(150,280)
t。end_fill()
#圍巾
t。fillcolor(“#ff7f00”)
t。begin_fill()
t。seth(0)#絕對角度
t。fd(200)#前進200
t。circle(-5,90)
t。fd(10)
t。circle(-5,90)
t。fd(207)
t。circle(-5,90)
t。fd(10)
t。circle(-5,90)
t。end_fill()
#臉
t。fd(183)
t。fillcolor(‘#ffffff’)
t。begin_fill()
t。lt(45)
t。circle(120, 100)
t。seth(90)
eyes()
t。seth(180)
t。up()
t。fd(60)
t。down()
t。seth(90)
eyes()
t。up()
t。seth(180)
t。fd(64)
t。down()
t。seth(215)
t。circle(120, 100)
t。end_fill()
#鼻子
my_goto(-10,158)
t。fillcolor(“#ffcc00”)
t。begin_fill()
t。circle(20)
t。end_fill()
#嘴巴
my_goto(5,148)
t。seth(270)
t。fd(100)
t。seth(0)
t。circle(120,50)
t。seth(230)
t。circle(-120,100)
# 畫鬍鬚
beard(-37,135,165,60)
beard(-37,125,180,60)
beard(-37,115,193,60)
beard(37,135,15,60)
beard(37,125,0,60)
beard(37,115,-13,60)
#畫身體
my_goto(0, 0)
t。seth(0)
t。up()
t。circle(150, 50)
t。down()
t。seth(30)
t。fd(40)
t。seth(70)
t。circle(-30, 270)
t。fillcolor(‘#00a0de’)
t。begin_fill()
t。seth(230)
t。fd(80)
t。seth(90)
t。circle(1000, 1)
t。seth(-89)
t。circle(-1000, 10)
t。seth(180)
t。fd(70)
t。seth(90)
t。circle(30, 180)
t。seth(180)
t。fd(70)
t。seth(100)
t。circle(-1000, 9)
t。seth(-86)
t。circle(1000, 2)
t。seth(230)
t。fd(40)
t。circle(-30, 230)
t。seth(45)
t。fd(81)
t。seth(0)
t。fd(203)
t。circle(5, 90)
t。fd(10)
t。circle(5, 90)
t。fd(7)
t。seth(40)
t。circle(150, 10)
t。seth(30)
t。fd(40)
t。end_fill()
# 左手
hand(70,‘#ffffff’,-30)
# 右手
my_goto(-133。97, -91。81)
hand(50,‘#ffffff’,30)
# 腳
foot(103。74,-182。59,0,‘#ffffff’,15,-15,180,90,-15,180,10)
foot(-96。26,-182。59,180,‘#ffffff’,15,15,180,90,15,180,10)
# 口袋
my_goto(-103。42, 15。09)
t。seth(0)
t。fd(38)
t。seth(230)
t。begin_fill()
t。circle(90, 260)
t。end_fill()
my_goto(5, -40)
t。seth(0)
t。fd(70)
t。seth(-90)
t。circle(-70, 180)
t。seth(0)
t。fd(70)
#鈴鐺
my_goto(-103。42, 15。09)
t。fd(90)
t。seth(70)
t。fillcolor(‘#ffd200’)
t。begin_fill()
t。circle(-20)
t。end_fill()
t。seth(170)
t。fillcolor(‘#ffd200’)
t。begin_fill()
t。circle(-2, 180)
t。seth(10)
t。circle(-100, 22)
t。circle(-2, 180)
t。seth(180-10)
t。circle(100, 22)
t。end_fill()
t。goto(-13。42, 15。09)
t。seth(250)
t。circle(20, 110)
t。seth(90)
t。fd(15)
t。dot(10)#dot繪製一個指定直徑和顏色的圓點。
my_goto(0, -150)
# 眼睛
t。seth(0)
my_goto(-20, 195)
t。fillcolor(‘#000000’)
t。begin_fill()
t。circle(13)
t。end_fill()
t。pensize(6)
my_goto(20, 205)
t。seth(75)
t。circle(-10, 150)
t。pensize(3)
my_goto(-17, 200)
t。seth(0)
t。fillcolor(‘#ffffff’)
t。begin_fill()
t。circle(5)
t。end_fill()
my_goto(0, 0)
t。exitonclick()#不關閉窗體