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

使用Python的Turtle繪制哆啦A夢(mèng)實(shí)例

 更新時(shí)間:2019年11月21日 10:48:47   作者:唐大鍋燉蟒蛇  
今天小編就為大家分享一篇使用Python的Turtle繪制哆啦A夢(mèng)實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

這是我?guī)啄昵盀榱司毩?xí)python的turtle庫(kù)而畫(huà)的,今天翻出了代碼,分享給大家。

這是我初學(xué)python時(shí)畫(huà)的,當(dāng)時(shí)還沒(méi)有面向?qū)ο蟮母拍?,也沒(méi)有采取類方法之類,純?cè)际止?,供大家參考?/p>

若有興趣可以自行優(yōu)化簡(jiǎn)潔代碼,有時(shí)間我也會(huì)重新寫(xiě)一遍。

畫(huà)出來(lái)的效果如下圖:

代碼如下:

# * -- utf-8 -- *
# Author: Tang
 
import turtle as t
 
t.speed(10)
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()

以上這篇使用Python的Turtle繪制哆啦A夢(mèng)實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 用virtualenv建立多個(gè)Python獨(dú)立虛擬開(kāi)發(fā)環(huán)境

    用virtualenv建立多個(gè)Python獨(dú)立虛擬開(kāi)發(fā)環(huán)境

    這篇文章主要為大家詳細(xì)介紹了用virtualenv建立多個(gè)Python獨(dú)立虛擬開(kāi)發(fā)環(huán)境,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • 實(shí)時(shí)獲取Python的print輸出流方法

    實(shí)時(shí)獲取Python的print輸出流方法

    今天小編就為大家分享一篇實(shí)時(shí)獲取Python的print輸出流方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-01-01
  • jupyter notebook使用argparse傳入list參數(shù)

    jupyter notebook使用argparse傳入list參數(shù)

    這篇文章主要介紹了jupyter notebook使用argparse傳入list參數(shù),jupyter notebook其實(shí)是可以使用 argparse來(lái)調(diào)用參數(shù)的,只要把參數(shù)轉(zhuǎn)為list即可,下面來(lái)看看具體的實(shí)現(xiàn)過(guò)程吧
    2022-01-01
  • Python實(shí)現(xiàn)處理圖片水印的方法詳解

    Python實(shí)現(xiàn)處理圖片水印的方法詳解

    這篇文章主要為大家詳細(xì)介紹了如何利用Python實(shí)現(xiàn)處理圖片水印的相關(guān)資料,主要是實(shí)現(xiàn)圖片水印的去除效果,感興趣的小伙伴可以嘗試一下
    2022-11-11
  • 用Python進(jìn)行一些簡(jiǎn)單的自然語(yǔ)言處理的教程

    用Python進(jìn)行一些簡(jiǎn)單的自然語(yǔ)言處理的教程

    這篇文章主要介紹了用Python進(jìn)行一些簡(jiǎn)單的自然語(yǔ)言處理的教程,主要用到了pandas和collections庫(kù),需要的朋友可以參考下
    2015-03-03
  • Python中Thop庫(kù)的基本用例和參數(shù)說(shuō)明

    Python中Thop庫(kù)的基本用例和參數(shù)說(shuō)明

    這篇文章主要給大家介紹了關(guān)于Python中Thop庫(kù)的基本用例和參數(shù)說(shuō)明的相關(guān)資料,THOP是PyTorch非常實(shí)用的一個(gè)第三方庫(kù),可以統(tǒng)計(jì)模型的 FLOPs 和參數(shù)量,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-05-05
  • 在Pytorch中簡(jiǎn)單使用tensorboard

    在Pytorch中簡(jiǎn)單使用tensorboard

    今天給大家?guī)?lái)的是關(guān)于Python的相關(guān)知識(shí),文章圍繞著Pytorch使用tensorboard展開(kāi),文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下
    2021-06-06
  • 用python寫(xiě)個(gè)顏值評(píng)分器篩選最美主播

    用python寫(xiě)個(gè)顏值評(píng)分器篩選最美主播

    這篇文章主要介紹了我如何用python寫(xiě)顏值評(píng)分器,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-08-08
  • Windows11使用Cpython?編譯文件報(bào)錯(cuò)?error:?Unable?to?find?vcvarsall.bat?完美解決方法

    Windows11使用Cpython?編譯文件報(bào)錯(cuò)?error:?Unable?to?find?vcvars

    這篇文章主要介紹了Windows11使用Cpython編譯文件報(bào)錯(cuò)error:Unable?to find?vcvarsall.bat完美解決方法,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-05-05
  • Python之用戶輸入的實(shí)例

    Python之用戶輸入的實(shí)例

    今天小編就為大家分享一篇Python之用戶輸入的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-06-06

最新評(píng)論