《啥是佩琪》之python畫佩琪源碼

from turtle import *

def nose(x, y):# 鼻子

? ? penup()# 提起筆

? ? goto(x, y)# 定位

? ? pendown()# 落筆,開始畫

? ? setheading(-30)# 將烏龜?shù)姆较蛟O(shè)置為to_angle/為數(shù)字(0-東内贮、90-北莫换、180-西废境、270-南)

? ? begin_fill()# 準備開始填充圖形

? ? a =0.4

? ? for i in range(120):

????????if 0 <= i <30 or 60 <= i <90:

????????????a = a +0.08

? ? ? ? ? ? left(3)# 向左轉(zhuǎn)3度

? ? ? ? ? ? forward(a)# 向前走a的步長

? ? ? ? else:

????????????a = a -0.08

? ? ? ? ? ? left(3)

????????????forward(a)

????end_fill()# 填充完成

? ? penup()

????setheading(90)

????forward(25)

????setheading(0)

????forward(10)

????pendown()

????pencolor(255, 155, 192)# 畫筆顏色

? ? setheading(10)

????begin_fill()

????circle(5)

????color(160, 82, 45)# 返回或設(shè)置pencolor和fillcolor

? ? end_fill()

????penup()

????setheading(0)

????forward(20)

????pendown()

????pencolor(255, 155, 192)

????setheading(10)

????begin_fill()

????circle(5)

????color(160, 82, 45)

????end_fill()

def head(x, y):# 頭

????color((255, 155, 192), "pink")

????penup()

????goto(x, y)

????setheading(0)

????pendown()

? ? begin_fill()

????setheading(180)

????circle(300, -30)

????circle(100, -60)

? ? circle(80, -100)

????circle(150, -20)

????circle(60, -95)

????setheading(161)

????circle(-300, 15)

????penup()

????goto(-100, 100)

????pendown()

????setheading(-30)

????a =0.4

? ? for i in range(60):

????????if 0 <= i <30 or 60 <= i <90:

????????????a = a +0.08

? ? ? ? ? ? lt(3)# 向左轉(zhuǎn)3度

? ? ? ? ? ? fd(a)# 向前走a的步長

? ? ? ? else:

????????????a = a -0.08

? ? ? ? ? ? lt(3)

????????????fd(a)

????end_fill()


def ears(x, y):# 耳朵

? ? color((255, 155, 192), "pink")

????penup()# 提起筆移動

? ? goto(x, y)

????pendown()

????begin_fill()

????setheading(100)# 當(dāng)前朝100度方向移動

? ? circle(-50, 50)# 半徑50疾掰,弧度50

? ? circle(-10, 120)

????circle(-50, 54)

????end_fill()

????penup()

????setheading(90)

????forward(-12)

????setheading(0)

????forward(30)

????pendown()

????begin_fill()

????setheading(100)

????circle(-50, 50)

????circle(-10, 120)

????circle(-50, 56)

????end_fill()

def eyes(x, y):# 眼睛

? ? color((255, 155, 192), "white")

????penup()

????setheading(90)

????forward(-20)

????setheading(0)

????forward(-95)

????pendown()

????begin_fill()

????circle(15)

????end_fill()

????color("black")

????penup()

????setheading(90)

????forward(12)

????setheading(0)

????forward(-3)

????pendown()

????begin_fill()

????circle(3)

????end_fill()

????color((255, 155, 192), "white")

????penup()

????seth(90)

????forward(-25)

????seth(0)

????forward(40)

????pendown()

????begin_fill()

????circle(15)

????end_fill()

????color("black")

????penup()

????setheading(90)

????forward(12)

????setheading(0)

????forward(-3)

????pendown()

????begin_fill()

????circle(3)

????end_fill()

def cheek(x, y):# 腮

? ? color((255, 155, 192))

????penup()

????goto(x, y)

????pendown()

????setheading(0)

????begin_fill()

????circle(30)

????end_fill()

def mouth(x, y):# 嘴

? ? color(239, 69, 19)

????penup()

????goto(x, y)

????pendown()

????setheading(-80)

????circle(30, 40)

????circle(40, 80)

def setting():# 參數(shù)設(shè)置

? ? pensize(4)

????hideturtle()# 使烏龜無形(隱藏)

? ? colormode(255)# 將其設(shè)置為1.0或255.隨后 顏色三元組的r靖诗,g,b值必須在0 .. cmode范圍內(nèi)

? ? color((255, 155, 192), "pink")

????setup(840, 500)

????speed(10)

def main():

????setting()# 畫布桐磁、畫筆設(shè)置

? ? nose(-100, 100)# 鼻子

? ? head(-69, 167)# 頭

? ? ears(0, 160)# 耳朵

? ? eyes(0, 140)# 眼睛

? ? cheek(80, 10)# 腮

? ? mouth(-20, 30)# 嘴

? ? done()

if __name__ =='__main__':

????main()

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市讲岁,隨后出現(xiàn)的幾起案子我擂,更是在濱河造成了極大的恐慌,老刑警劉巖缓艳,帶你破解...
    沈念sama閱讀 222,627評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件校摩,死亡現(xiàn)場離奇詭異,居然都是意外死亡阶淘,警方通過查閱死者的電腦和手機衙吩,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,180評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來溪窒,“玉大人分井,你說我怎么就攤上這事∶姑停” “怎么了尺锚?”我有些...
    開封第一講書人閱讀 169,346評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長惜浅。 經(jīng)常有香客問我瘫辩,道長,這世上最難降的妖魔是什么坛悉? 我笑而不...
    開封第一講書人閱讀 60,097評論 1 300
  • 正文 為了忘掉前任伐厌,我火速辦了婚禮,結(jié)果婚禮上裸影,老公的妹妹穿的比我還像新娘挣轨。我一直安慰自己,他們只是感情好轩猩,可當(dāng)我...
    茶點故事閱讀 69,100評論 6 398
  • 文/花漫 我一把揭開白布卷扮。 她就那樣靜靜地躺著荡澎,像睡著了一般扫俺。 火紅的嫁衣襯著肌膚如雪危喉。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,696評論 1 312
  • 那天铐尚,我揣著相機與錄音鞭铆,去河邊找鬼或衡。 笑死,一個胖子當(dāng)著我的面吹牛车遂,可吹牛的內(nèi)容都是我干的封断。 我是一名探鬼主播,決...
    沈念sama閱讀 41,165評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼舶担,長吁一口氣:“原來是場噩夢啊……” “哼坡疼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起柄沮,我...
    開封第一講書人閱讀 40,108評論 0 277
  • 序言:老撾萬榮一對情侶失蹤回梧,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后祖搓,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體狱意,經(jīng)...
    沈念sama閱讀 46,646評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,709評論 3 342
  • 正文 我和宋清朗相戀三年拯欧,在試婚紗的時候發(fā)現(xiàn)自己被綠了详囤。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,861評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡镐作,死狀恐怖藏姐,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情该贾,我是刑警寧澤羔杨,帶...
    沈念sama閱讀 36,527評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站杨蛋,受9級特大地震影響兜材,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜逞力,卻給世界環(huán)境...
    茶點故事閱讀 42,196評論 3 336
  • 文/蒙蒙 一曙寡、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧寇荧,春花似錦举庶、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,698評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽镀琉。三九已至,卻和暖如春添祸,著一層夾襖步出監(jiān)牢的瞬間滚粟,已是汗流浹背寻仗。 一陣腳步聲響...
    開封第一講書人閱讀 33,804評論 1 274
  • 我被黑心中介騙來泰國打工刃泌, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人署尤。 一個月前我還...
    沈念sama閱讀 49,287評論 3 379
  • 正文 我出身青樓耙替,卻偏偏與公主長得像,于是被迫代替她去往敵國和親曹体。 傳聞我的和親對象是個殘疾皇子俗扇,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,860評論 2 361

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,350評論 0 10
  • 一、快捷鍵 ctr+b 執(zhí)行ctr+/ 單行注釋ctr+c ...
    o_8319閱讀 5,830評論 2 16
  • 通過閱讀《干法》一書箕别,我從中學(xué)到了很多铜幽。工作能夠鍛煉人性、磨礪心智串稀,工作是人最尊貴除抛、最重要、最有價值的行為母截。獲得心...
    扮途人_f3ad閱讀 183評論 0 1
  • 今天早上奶奶去地里看菜到忽,我和我哥哥睡醒就看了一個電視劇,名字叫五號特工組清寇。我特別喜歡里面的馬云飛喘漏,馬云飛可以同時拿...
    高金鑫a閱讀 177評論 0 0
  • 初中三年 卷土重來 思忖多日,決定此文還是從小升初寫起华烟,我們的小升初是失敗的翩迈,以四分之差無緣交大附中本部,錄到了浐...
    阿楠613閱讀 2,420評論 3 10