import turtle as t
def infoPrt():
print('coordinate: ' + str(t.pos()))
print('angle: ' + str(t.heading()))
t.pensize(3)
t.hideturtle()
t.colormode(255)
t.color("black")
t.setup(700, 650)
t.speed(10)
t.st()
#t.dot()
t.pu()
#t.goto(-150,100)
t.goto(-210,86)
t.pd()
infoPrt()
# 头
print('头')
t.seth(85)
t.circle(-100,50)
#t.seth(78)
#t.circle(-100,25)
infoPrt()
t.seth(25)
t.circle(-170,50)
infoPrt()
# 右耳
print('右耳')
t.seth(40)
#t.circle(-250,52)
t.circle(-250,30)
infoPrt()
# 右耳尖
t.begin_fill()
# 左
t.circle(-250,22)
#t.fillcolor("pink")
# 右
t.seth(227)
t.circle(-270, 15)
prePos = t.pos()
infoPrt()
# 尾巴
t.pu()
t.setpos(p_tail)
t.pd()
t.begin_fill()
t.seth(50)
t.fd(25)
t.seth(-50)
t.fd(30)
p_tail1=t.pos
t.seth(-140)
t.fd(36)
t.end_fill()
t.seth(39)
# 右尾和h1
t.fd(72)
# 右尾和v1
t.seth(125)
t.fd(48)
# 右尾和h2
t.seth(40)
t.fd(53)
# 右尾和v2
t.seth(88)
t.fd(45)
# 右尾和h3
t.seth(35)
t.fd(105)
# 右尾和v3
t.seth(105)
t.circle(850, 8)
#t.fd(105)
t.seth(215)
#t.fd(125)
t.circle(850, 11)
t.seth(280)
t.fd(110)
t.seth(220)
t.fd(50)
t.seth(309)
t.fd(56)
以上只提供部分代碼,因為完整的多達 360 行。其實使用 Turtle 海龜模組畫圖,原理非常簡單,只要先定位好座標再畫出曲線即可。難的是每個部位的位置如何定位。Python 初學者不想畫那麼複雜的話,可先學習只畫出皮卡丘的臉即可 (如下圖)。作法參考另一位網友的 CSDN 博客文章:
「教大家用python画皮卡丘的脸」。
推薦閱讀:
接觸Python讓你長智慧!(上)
接觸Python讓你長智慧!(下)
雅婷跟Python也有關係!?
神奇的Java課程-竟可讓人從零經驗到成為工程師不用一年!!?
達內教育開幕 培養台灣IT人才進入全球企業
達內教育學員見證
挑對Java課程,讓你從零起點到獨當一面的工程師只需六個月!




