最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用Python的Turtle繪制哆啦A夢實例

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

這是我?guī)啄昵盀榱司毩昿ython的turtle庫而畫的,今天翻出了代碼,分享給大家。

這是我初學(xué)python時畫的,當時還沒有面向?qū)ο蟮母拍?,也沒有采取類方法之類,純原始手工,供大家參考。

若有興趣可以自行優(yōu)化簡潔代碼,有時間我也會重新寫一遍。

畫出來的效果如下圖:

代碼如下:

# * -- 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的步長
  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()

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

相關(guān)文章

  • Django進階之CSRF的解決

    Django進階之CSRF的解決

    這篇文章主要介紹了Django進階之CSRF的解決,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • matplotlib subplots 設(shè)置總圖的標題方法

    matplotlib subplots 設(shè)置總圖的標題方法

    今天小編就為大家分享一篇matplotlib subplots 設(shè)置總圖的標題方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • Django添加KindEditor富文本編輯器的使用

    Django添加KindEditor富文本編輯器的使用

    今天小編就為大家分享一篇關(guān)于Django添加KindEditor富文本編輯器的使用,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • 淺析PEP570新語法: 只接受位置參數(shù)

    淺析PEP570新語法: 只接受位置參數(shù)

    本文通過一個例子給大家介紹了PEP570新語法: 只接受位置參數(shù)的一些知識,感興趣的朋友跟隨小編一起看看吧
    2019-10-10
  • TensorFLow 變量命名空間實例

    TensorFLow 變量命名空間實例

    今天小編就為大家分享一篇TensorFLow 變量命名空間實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-02-02
  • python實現(xiàn)保留小數(shù)位數(shù)的3種方法

    python實現(xiàn)保留小數(shù)位數(shù)的3種方法

    本文主要介紹了python實現(xiàn)保留小數(shù)位數(shù)的3種方法,包括格式化字符串,format()函數(shù)和round()函數(shù),具有一定的參考價值,感興趣的可以了解一下
    2025-03-03
  • 使用llama?Index幫你訓(xùn)練pdf的示例詳解

    使用llama?Index幫你訓(xùn)練pdf的示例詳解

    這篇文章主要為大家介紹了使用llama?Index?幫你訓(xùn)練pdf,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-03-03
  • TensorFlow命名空間和TensorBoard圖節(jié)點實例

    TensorFlow命名空間和TensorBoard圖節(jié)點實例

    今天小編就為大家分享一篇TensorFlow命名空間和TensorBoard圖節(jié)點實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-01-01
  • Keras loss函數(shù)剖析

    Keras loss函數(shù)剖析

    這篇文章主要介紹了Keras loss函數(shù)剖析,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • Python棧算法的實現(xiàn)與簡單應(yīng)用示例

    Python棧算法的實現(xiàn)與簡單應(yīng)用示例

    這篇文章主要介紹了Python棧算法的實現(xiàn)與簡單應(yīng)用,簡單講述了棧的原理并結(jié)合實例形式給出了基于棧實現(xiàn)的進制轉(zhuǎn)換與括號匹配等相關(guān)使用技巧,需要的朋友可以參考下
    2017-11-11

最新評論

苍山县| 循化| 凤冈县| 定襄县| 容城县| 深水埗区| 姚安县| 双江| 始兴县| 中宁县| 西乌珠穆沁旗| 汉源县| 商南县| 仁布县| 恭城| 瓦房店市| 安乡县| 衡东县| 平邑县| 遂昌县| 颍上县| 丰县| 丽水市| 鄱阳县| 牡丹江市| 建湖县| 静乐县| 洛南县| 平南县| 福清市| 海城市| 玛纳斯县| 资中县| 德化县| 安多县| 湄潭县| 哈尔滨市| 大竹县| 沿河| 兴城市| 通渭县|