欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python利用Turtle繪制哆啦A夢(mèng)和小豬佩奇

 更新時(shí)間:2022年04月04日 09:50:16   作者:電力系統(tǒng)與算法之美  
turtle庫(kù)是python的基礎(chǔ)繪圖庫(kù),經(jīng)常被用來(lái)介紹編程知識(shí)的方法庫(kù),是標(biāo)準(zhǔn)庫(kù)之一,利用turtle可以制作很多復(fù)雜的繪圖。本文將為大家介紹通過(guò)turtle庫(kù)繪制制哆啦A夢(mèng)和小豬佩奇,感興趣的小伙伴可以學(xué)習(xí)一下

1.哆啦A夢(mèng)

“只要把愿望系在竹竿上請(qǐng)求月亮女神,心愿便能達(dá)成”。我超喜歡這句話。

哆啦A夢(mèng)的創(chuàng)造要追溯到1969年的某個(gè)截稿日,作者藤子·F·不二雄的家里突然闖進(jìn)了一只小貓,雖然很快就要截稿了,但作者還是和小貓玩了起來(lái),還替小貓撓虱子,而這一撓就是幾個(gè)小時(shí)。等作者發(fā)現(xiàn)時(shí)間不夠用的時(shí)候,已經(jīng)來(lái)不及完成稿子。這時(shí)作者像熱鍋上的螞蟻?zhàn)邅?lái)走去,突然踢到了女兒的不倒翁玩具,于是作者靈光一現(xiàn),把貓的形象和不倒翁結(jié)合起來(lái),就創(chuàng)造了哆啦A夢(mèng)。

2.小豬佩奇

對(duì)比于國(guó)內(nèi)的《喜羊羊與灰太狼》和《熊出沒(méi)》,我希望有一天喜羊羊被灰太狼燉了、熊大被光頭強(qiáng)一槍打中,然后直接賣到動(dòng)物園。(哈哈哈......)可是這個(gè)想法一直沒(méi)實(shí)現(xiàn),有些失落。還是看小豬佩奇吧:

由英國(guó)E1 Kids于2004年5月31日發(fā)行首播后,其動(dòng)畫(huà)片已于全球180個(gè)地區(qū)播放,現(xiàn)已播出6季;

中國(guó)中央電視臺(tái)少兒頻道也在熱播之中,極簡(jiǎn)的動(dòng)畫(huà)風(fēng)格,幽默的對(duì)話語(yǔ)調(diào),深具教育意義的故事情節(jié),不僅能讓學(xué)齡前兒童學(xué)習(xí)知識(shí),更能讓小朋友們從小養(yǎng)成良好的生活習(xí)慣體驗(yàn)生活,深受全球各地小朋友們以及其家長(zhǎng)們的喜愛(ài)。

3.Python代碼實(shí)現(xiàn)(哆啦A夢(mèng))

import turtle as t
t.title('哆啦A夢(mèng)')
# t.speed(5)
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的步長(zhǎng)
    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的步長(zhǎng)
    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()

4.Python代碼實(shí)現(xiàn)(小豬佩奇 )

 
import turtle
from turtle import *
turtle.title('小豬佩奇')
 
def nose(x,y):
    """畫(huà)鼻子"""
    pensize(5)
    pencolor((255, 155, 192))
    penup()
    # 將海龜移動(dòng)到指定的坐標(biāo)
    goto(x,y)
    pendown()
    # 設(shè)置海龜?shù)姆较颍?-東、90-北、180-西、270-南)
    setheading(-30)
    begin_fill()
    fillcolor(255, 192, 203)
    a = 0.4
    for i in range(120):
        if 0 <= i < 30 or 60 <= i <90:
            a = a + 0.08
            # 向左轉(zhuǎn)3度
            left(3)
            # 向前走
            forward(a)
        else:
            a = a - 0.08
            left(3)
            forward(a)
    end_fill()
    penup()
    setheading(90)
    forward(25)
    setheading(0)
    forward(10)
    pendown()
    """設(shè)置畫(huà)筆的顏色(紅, 綠, 藍(lán))"""
    pencolor(255, 155, 192)
    setheading(10)
    begin_fill()
    circle(5)
    color(160, 82, 45)
    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):
    """畫(huà)頭"""
    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的步長(zhǎng)
        else:
            a = a - 0.08
            lt(3)
            fd(a)
    end_fill()
 
 
def ears(x,y):
    """畫(huà)耳朵"""
    color((255, 155, 192), "pink")
    penup()
    goto(x, y)
    pendown()
    begin_fill()
    setheading(100)
    circle(-50, 50)
    circle(-10, 120)
    circle(-50, 54)
    end_fill()
    penup()
    setheading(90)
    forward(-12)
    setheading(0)
    forward(30)
    pendown()
    begin_fill()
    setheading(90)
    circle(-50, 50)
    circle(-10, 120)
    circle(-50, 56)
    end_fill()
 
 
def eyes(x,y):
    """畫(huà)眼睛"""
    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):
    """畫(huà)臉頰"""
    color((255, 155, 192))
    penup()
    goto(x,y)
    pendown()
    setheading(0)
    begin_fill()
    circle(30)
    end_fill()
 
 
def mouth(x,y):
    """畫(huà)嘴巴"""
    color(239, 69, 19)
    penup()
    goto(x, y)
    pendown()
    setheading(-80)
    circle(30, 40)
    circle(40, 80)
 
def body(x,y):
    '''畫(huà)身體'''
    penup()
    goto(x,y)
    pencolor('red')
    fillcolor(250,106,106)
    pendown()
    begin_fill()
    setheading(-66)
    circle(-450,17)
    setheading(180)
    forward(185)
    setheading(85)
    circle(-450,17)
    end_fill()
    '''右手'''
    penup()
    goto(110,-45)
    pendown()
    pensize(8)
    pencolor(255, 192, 203)
    setheading(30)
    circle(-400,10)
    penup()
    goto(167,-5)
    pendown()
    setheading(-120)
    forward(20)
    left(100)
    forward(20)
    '''左手'''
    penup()
    goto(-25,-45)
    pendown()
    pencolor(255, 192, 203)
    setheading(150)
    circle(400,10)
    penup()
    goto(-78,-6)
    pendown()
    setheading(-60)
    forward(20)
    right(100)
    forward(20)
 
def feet1(x,y):
    pensize(7)
    pencolor(255, 192, 203)
    penup()
    goto(x,y)
    setheading(-90)
    pendown()
    forward(10)
    penup()
    goto(x-12,y-10)
    pendown()
    pencolor(238,201,0)
    fillcolor(238,230,132)
    begin_fill()
    setheading(0)
    forward(24)
    right(90)
    forward(36)
    right(90)
    forward(40)
    circle(-10,180)
    forward(16)
    left(90)
    forward(12)
    end_fill()
 
def feet2(x,y):
    pensize(7)
    pencolor(255, 192, 203)
    penup()
    goto(x,y)
    setheading(-90)
    pendown()
    forward(10)
    penup()
    goto(x-12,y-10)
    pendown()
    pencolor(238,201,0)
    fillcolor(238,230,132)
    begin_fill()
    setheading(0)
    forward(24)
    right(90)
    forward(36)
    right(90)
    forward(40)
    circle(-10,180)
    forward(16)
    left(90)
    forward(12)
    end_fill()
 
def tail(x,y):
    pensize(8)
    penup()
    goto(x,y)
    pendown()
    pencolor(255, 192, 203)
    setheading(-5)
    circle(30,100)
    circle(10,180)
    circle(20,150)
 
def backg(x):
    penup()
    goto(-420,x)
    setheading(0)
    fillcolor(50,205,50)
    begin_fill()
    forward(840)
    right(90)
    forward(300)
    right(90)
    forward(840)
    right(90)
    forward(300)
    end_fill()
    setheading(0)
    fillcolor(0,191,255)
    begin_fill()
    forward(840)
    left(90)
    forward(600)
    left(90)
    forward(840)
    left(90)
    forward(600)
    end_fill()
 
def cloude1(x, y):
    """畫(huà)云"""
    penup()
    goto(x,y)
    setheading(90)
    fillcolor(255,255,255)
    begin_fill()
    a = 0.4
    for i in range(120):
        if 0 <= i < 30 or 60 <= i <90:
            a = a + 0.14
            # 向左轉(zhuǎn)3度
            left(3)
            # 向前走
            forward(a)
        else:
            a = a - 0.15
            left(3)
            forward(a)
    end_fill()
 
def cloude2(x, y):
    """畫(huà)云"""
    penup()
    goto(x,y)
    setheading(90)
    fillcolor(255,255,255)
    begin_fill()
    a = 0.4
    for i in range(120):
        if 0 <= i < 30 or 60 <= i <90:
            a = a + 0.15
            # 向左轉(zhuǎn)3度
            left(3)
            # 向前走
            forward(a)
        else:
            a = a - 0.13
            left(3)
            forward(a)
    end_fill()
 
def setting():
    """設(shè)置參數(shù)"""
    pensize(5)
    # 隱藏海龜
    hideturtle()
    colormode(255)
    color((255, 155, 192), "pink")
    setup(840, 700)
    speed(10)
 
 
def main():
    """主函數(shù)"""
    
    setting() 
    backg(0)
    body(105,-20)
    nose(-100, 100)
    head(-69, 167)
    ears(0, 160)
    eyes(0, 140)
    cheek(80, 10)
    mouth(-20, 30)
    feet1(10,-150)
    feet2(90,-150)
    tail(130,-110)
    cloude1(-200,200)
    cloude2(300,300)
    done()
 
 
if __name__ == '__main__':
    main()

以上就是Python利用Turtle繪制哆啦A夢(mèng)和小豬佩奇的詳細(xì)內(nèi)容,更多關(guān)于Python哆啦A夢(mèng) 小豬佩奇的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 盤點(diǎn)20個(gè)Python數(shù)據(jù)科學(xué)庫(kù)神器打造數(shù)據(jù)魔法世界

    盤點(diǎn)20個(gè)Python數(shù)據(jù)科學(xué)庫(kù)神器打造數(shù)據(jù)魔法世界

    數(shù)據(jù)科學(xué)家和分析師常常使用?Python?來(lái)處理數(shù)據(jù)、進(jìn)行分析和可視化,Python生態(tài)系統(tǒng)中有許多庫(kù),但有一些庫(kù)是數(shù)據(jù)科學(xué)家日常工作中必不可少的,本文將深入介紹20個(gè)重要的Python?庫(kù),包括示例代碼和用例
    2024-01-01
  • python通過(guò)urllib2爬網(wǎng)頁(yè)上種子下載示例

    python通過(guò)urllib2爬網(wǎng)頁(yè)上種子下載示例

    這篇文章主要介紹了通過(guò)urllib2、re模塊抓種子下載的示例,需要的朋友可以參考下
    2014-02-02
  • Pandas統(tǒng)計(jì)計(jì)數(shù)value_counts()的使用

    Pandas統(tǒng)計(jì)計(jì)數(shù)value_counts()的使用

    本文主要介紹了Pandas統(tǒng)計(jì)計(jì)數(shù)value_counts()的使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • python 基于opencv去除圖片陰影

    python 基于opencv去除圖片陰影

    這篇文章主要介紹了python 基于opencv去除圖片陰影的方法,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2021-01-01
  • python實(shí)現(xiàn)雙鏈表

    python實(shí)現(xiàn)雙鏈表

    這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)雙鏈表,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Django使用uwsgi部署時(shí)的配置以及django日志文件的處理方法

    Django使用uwsgi部署時(shí)的配置以及django日志文件的處理方法

    今天小編就為大家分享一篇Django使用uwsgi部署時(shí)的配置以及django日志文件的處理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-08-08
  • 用python爬取分析淘寶商品信息詳解技術(shù)篇

    用python爬取分析淘寶商品信息詳解技術(shù)篇

    這篇文章主要介紹了用python爬取分析淘寶商品信息的技術(shù),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-08-08
  • Python 安裝 virturalenv 虛擬環(huán)境的教程詳解

    Python 安裝 virturalenv 虛擬環(huán)境的教程詳解

    這篇文章主要介紹了Python 安裝 virturalenv 虛擬環(huán)境的教程,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-02-02
  • python異常的捕捉和補(bǔ)救實(shí)例詳解

    python異常的捕捉和補(bǔ)救實(shí)例詳解

    在本篇文章里小編給大家整理的是一篇關(guān)于python異常的捕捉和補(bǔ)救實(shí)例詳解內(nèi)容,有需要的朋友們可以跟著學(xué)習(xí)參考下。
    2021-06-06
  • Pygame游戲開(kāi)發(fā)之太空射擊實(shí)戰(zhàn)盾牌篇

    Pygame游戲開(kāi)發(fā)之太空射擊實(shí)戰(zhàn)盾牌篇

    相信大多數(shù)8090后都玩過(guò)太空射擊游戲,在過(guò)去游戲不多的年代太空射擊自然屬于經(jīng)典好玩的一款了,今天我們來(lái)自己動(dòng)手實(shí)現(xiàn)它,在編寫(xiě)學(xué)習(xí)中回顧過(guò)往展望未來(lái),在本課中,我們將為玩家添加一個(gè)盾牌以及一個(gè)用于顯示盾牌等級(jí)的欄
    2022-08-08

最新評(píng)論