Python+Turtle繪制可愛的多啦A夢的示例代碼
1 送她的多啦A夢
一個哆啦A夢讓她開心開心好久好久。我也很開心,昨天送了一個實體模型,今天用Python代碼再弄一個送給她。
哆啦A夢(日語:ドラえもん,英語:Doraemon),舊譯為機(jī)器貓,日本漫畫《多啦A夢》及其衍生作品中的貓型機(jī)器人,本作的主人公。名字的意思是銅鑼(ドラ)衛(wèi)門(えもん)。
哆啦A夢肚子上擁有四次元口袋,這個口袋直接通往四次元空間,再多的東西也放得下。害怕老鼠。平時的職責(zé)是照顧野比大雄。
2 白駒過隙
雖說雁過無痕,歲月無聲,而白駒過隙的光陰卻在生命的每個角落不著痕跡的流,總是蕩漾在我渺遠(yuǎn)的心跡,很懷念。讓它停留在記憶的沙灘上,混入蚌中,化作一顆最美的珍珠.....
她的光環(huán)
天空很蔚藍(lán)也是你的主色
我送你的紅禮巾系著金色鈴鐺
最后的擁抱你像棉花糖一樣樣的柔軟哆啦A夢
請把我最珍貴的東西
都裝進(jìn)你的百寶袋
3 Python代碼實現(xiàn)
import turtle as t # t.speed(3) t.title('我的小公主,哆啦A夢') t.pensize(8) t.hideturtle() t.screensize(500, 500, bg='white') #========貓臉======== t.fillcolor('#00A1E8') t.begin_fill() t.circle(120) t.end_fill() t.pensize(3) t.fillcolor('white') t.begin_fill() t.circle(100) t.end_fill() t.pu() t.home() t.goto(0, 134) t.pd() t.pensize(4) t.fillcolor("#EA0014") t.begin_fill() t.circle(18) t.end_fill() t.pu() t.goto(7, 155) t.pensize(2) t.color('white', 'white') t.pd() t.begin_fill() t.circle(4) t.end_fill() t.pu() t.goto(-30, 160) t.pensize(4) t.pd() t.color('black', 'white') t.begin_fill() a = 0.4 for i in range(120): if 0 <= i < 30 or 60 <= i < 90: a = a + 0.08 t.lt(3) # 向左轉(zhuǎn)3度 t.fd(a) # 向前走a的步長 else: a = a - 0.08 t.lt(3) t.fd(a) t.end_fill() t.pu() t.goto(30, 160) t.pensize(4) t.pd() t.color('black', 'white') t.begin_fill() for i in range(120): if 0 <= i < 30 or 60 <= i < 90: a = a + 0.08 t.lt(3) # 向左轉(zhuǎn)3度 t.fd(a) # 向前走a的步長 else: a = a - 0.08 t.lt(3) t.fd(a) t.end_fill() t.pu() t.goto(-38, 190) t.pensize(8) t.pd() t.right(-30) t.forward(15) t.right(70) t.forward(15) t.pu() t.goto(15, 185) t.pensize(4) t.pd() t.color('black', 'black') t.begin_fill() t.circle(13) t.end_fill() t.pu() t.goto(13, 190) t.pensize(2) t.pd() t.color('white', 'white') t.begin_fill() t.circle(5) t.end_fill() t.pu() t.home() t.goto(0, 134) t.pensize(4) t.pencolor('black') t.pd() t.right(90) t.forward(40) t.pu() t.home() t.goto(0, 124) t.pensize(3) t.pencolor('black') t.pd() t.left(10) t.forward(80) t.pu() t.home() t.goto(0, 114) t.pensize(3) t.pencolor('black') t.pd() t.left(6) t.forward(80) t.pu() t.home() t.goto(0, 104) t.pensize(3) t.pencolor('black') t.pd() t.left(0) t.forward(80) #====左邊的胡子==== t.pu() t.home() t.goto(0, 124) t.pensize(3) t.pencolor('black') t.pd() t.left(170) t.forward(80) t.pu() t.home() t.goto(0, 114) t.pensize(3) t.pencolor('black') t.pd() t.left(174) t.forward(80) t.pu() t.home() t.goto(0, 104) t.pensize(3) t.pencolor('black') t.pd() t.left(180) t.forward(80) t.pu() t.goto(-70, 70) t.pd() t.color('black', 'red') t.pensize(6) t.seth(-60) t.begin_fill() t.circle(80, 40) t.circle(80, 80) t.end_fill() t.pu() t.home() t.goto(-80, 70) t.pd() t.forward(160) t.pu() t.home() t.goto(-50, 50) t.pd() t.pensize(1) t.fillcolor("#eb6e1a") t.seth(40) t.begin_fill() t.circle(-40, 40) t.circle(-40, 40) t.seth(40) t.circle(-40, 40) t.circle(-40, 40) t.seth(220) t.circle(-80, 40) t.circle(-80, 40) t.end_fill() #====領(lǐng)帶===== t.pu() t.goto(-70, 12) t.pensize(14) t.pencolor('red') t.pd() t.seth(-20) t.circle(200, 30) t.circle(200, 10) #====鈴鐺===== t.pu() t.goto(0, -46) t.pd() t.pensize(3) t.color("black", '#f8d102') t.begin_fill() t.circle(25) t.end_fill() t.pu() t.goto(-5, -40) t.pd() t.pensize(2) t.color("black", '#79675d') t.begin_fill() t.circle(5) t.end_fill() t.pensize(3) t.right(115) t.forward(7) t.mainloop()
到此這篇關(guān)于Python+Turtle繪制可愛的多啦A夢的示例代碼的文章就介紹到這了,更多相關(guān)Python Turtle多啦A夢內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
pytest文檔內(nèi)置fixture的request詳情
這篇文章主要介紹了pytest文檔內(nèi)置fixture的request詳情,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-08-08Python進(jìn)階學(xué)習(xí)之帶你探尋Python類的鼻祖-元類
這篇文章主要介紹了Python進(jìn)階學(xué)習(xí)之帶你探尋Python類的鼻祖-元類,文中有非常詳細(xì)的解釋,對正在學(xué)習(xí)python的小伙伴們有很好的幫助,需要的朋友可以參考下2021-05-05python網(wǎng)絡(luò)爬蟲精解之正則表達(dá)式的使用說明
正則表達(dá)式是對字符串操作的一種邏輯公式,就是用事先定義好的一些特定字符、及這些特定字符的組合,組成一個“規(guī)則字符串”,這個“規(guī)則字符串”用來表達(dá)對字符串的一種過濾邏輯2021-09-09Python安裝Numpy和matplotlib的方法(推薦)
下面小編就為大家?guī)硪黄狿ython安裝Numpy和matplotlib的方法(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11