日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

用python画动态皮卡丘_利用Python绘制萌萌哒的皮卡丘

發布時間:2024/10/8 python 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用python画动态皮卡丘_利用Python绘制萌萌哒的皮卡丘 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

開發工具

Python版本:3.6.4

相關模塊:

turtle模塊。

環境搭建

安裝Python并添加到環境變量即可。

在cmd窗口運行"pikachu.py"文件即可。

效果如下:

turtle文檔:

https://docs.python.org/zh-cn/3.7/library/turtle.html

代碼里有不懂的可以參考這個turtle文檔~這里只介紹一下用到的:

seth:設置朝向;

fd:前進;

circle:畫圓;

fillcolor:填充顏色;

pensize:畫筆粗細;

speed:速度;

hideturtle:隱藏海龜;

screensize:設置屏幕大小;

begin_fill:開始填充;

end_fill:結束填充;

penup:畫筆抬起;

pendown:畫筆落下(此時移動將畫線)。

源碼

'''

Python學習交流群:960410445

'''

import turtle

# 畫鼻子

def drawNose():

turtle.penup()

turtle.seth(90)

turtle.fd(100)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('black')

turtle.seth(45)

turtle.fd(25)

turtle.seth(135)

turtle.circle(25, 95)

turtle.seth(315)

turtle.fd(25)

turtle.end_fill()

# 畫眼睛

def drawEyes(seth, fd, r):

turtle.penup()

turtle.seth(seth)

turtle.fd(fd)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('black')

turtle.circle(50)

turtle.end_fill()

turtle.penup()

turtle.circle(50, r)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('white')

turtle.circle(20)

turtle.end_fill()

# 畫臉

def drawFace(seth, fd):

turtle.penup()

turtle.seth(seth)

turtle.fd(fd)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('red')

turtle.circle(70)

turtle.end_fill()

# 畫嘴巴

def drawLip():

turtle.penup()

turtle.seth(135)

turtle.fd(250)

turtle.pendown()

turtle.seth(-300)

turtle.circle(30, -65)

turtle.begin_fill()

turtle.fillcolor('Firebrick')

turtle.seth(165)

turtle.fd(140)

turtle.seth(195)

turtle.fd(140)

turtle.seth(-360)

turtle.circle(30, -65)

turtle.penup()

turtle.seth(-60)

turtle.circle(30, 65)

turtle.pendown()

turtle.seth(-70)

turtle.fd(240)

turtle.circle(55, 140)

turtle.seth(70)

turtle.fd(240)

turtle.end_fill()

turtle.seth(-110)

turtle.fd(80)

turtle.begin_fill()

turtle.fillcolor('Firebrick')

turtle.seth(120)

turtle.circle(120, 123)

turtle.seth(-70)

turtle.fd(165)

turtle.circle(55, 140)

turtle.seth(72)

turtle.fd(165)

turtle.end_fill()

# 主函數

def main():

turtle.pensize(4)

turtle.hideturtle()

turtle.setup(1000, 600)

turtle.speed(10)

turtle.screensize(bg='yellow')

drawNose()

drawEyes(160, 250, 60)

drawEyes(-9.5, 530, 230)

drawFace(195, 600)

drawFace(-11, 720)

drawLip()

turtle.done()

if __name__ == '__main__':

main()

總結

以上是生活随笔為你收集整理的用python画动态皮卡丘_利用Python绘制萌萌哒的皮卡丘的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。