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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python画圆形螺旋线_宝宝爱看小猪佩奇,很简单,让我们用python搞定它

發(fā)布時間:2025/3/20 python 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python画圆形螺旋线_宝宝爱看小猪佩奇,很简单,让我们用python搞定它 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

現(xiàn)在很多寶寶喜歡看小豬佩奇,今天就教大家用python的海龜畫圖畫一個乖巧萌萌的小豬佩奇,引導(dǎo)對編程產(chǎn)生濃濃 的興趣。

畫圖前引導(dǎo)

1、讓我們打開百度,輸入python進(jìn)入python官網(wǎng)

2、在官網(wǎng)選擇docs菜單,在左上角選擇中文

3、點擊右邊的標(biāo)準(zhǔn)庫參考,往下拉找到程序框架里邊的turtle--海龜繪圖,點擊進(jìn)入,查看海龜繪圖的基本操作

小豬佩奇的畫圖思路

看了海龜畫圖的基本操作后,了解每個函數(shù)的基本參數(shù)設(shè)置就很簡單了

1、先畫豬鼻子

2、畫頭

3、畫耳朵

4、畫眼睛

5、畫腮紅

6、畫嘴

7、畫身體

8、畫小手

9、畫腳丫

10、畫尾巴

畫豬鼻子

我們定義一個draw_nose()函數(shù)來畫豬鼻子,首先畫筆抬起,坐標(biāo)移動到-100,100處,畫筆落下,設(shè)置方向,開始填充,設(shè)置一個循環(huán)畫橢圓形,停止填充,抬起畫筆等等等就不一一講解了:

def draw_nose():

''' 先畫鼻子'''

t.pu()

t.goto(-100, 100)

t.pd()

t.seth(-30)

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.seth(90)

t.fd(25)

t.seth(0)

t.fd(10)

t.pd()

t.pencolor(255, 155, 192)

t.seth(10)

t.begin_fill()

t.circle(5)

t.color(160, 82, 45)

t.end_fill()

t.pu()

t.seth(0)

t.fd(20)

t.pd()

t.pencolor(255, 155, 192)

t.seth(10)

t.begin_fill()

t.circle(5)

t.color(160, 82, 45)

t.end_fill()

畫豬頭

定義一個draw_head函數(shù)來畫佩奇的頭

def draw_head():

''' 畫頭'''

t.speed('normal')

t.color((255, 155, 192), "pink")

t.pu()

t.seth(90)

t.fd(41)

t.seth(0)

t.fd(0)

t.pd()

t.begin_fill()

t.seth(180)

t.circle(300, -30)

t.circle(100, -60)

t.circle(80, -100)

t.circle(150, -20)

t.circle(60, -95)

t.seth(161)

t.circle(-300, 15)

t.pu()

t.goto(-100, 100)

t.pd()

t.seth(-30)

a = 0.4

for i in range(60):

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()

畫豬耳朵

我們定義一個draw_ear()函數(shù)來畫豬耳朵:

def draw_ear():

'''畫耳朵'''

t.color((255, 155, 192), "pink")

t.pu()

t.seth(90)

t.fd(-7)

t.seth(0)

t.fd(70)

t.pd()

t.begin_fill()

t.seth(100)

t.circle(-50, 50)

t.circle(-10, 120)

t.circle(-50, 54)

t.end_fill()

t.pu()

t.seth(90)

t.fd(-12)

t.seth(0)

t.fd(30)

t.pd()

t.begin_fill()

t.seth(100)

t.circle(-50, 50)

t.circle(-10, 120)

t.circle(-50, 56)

t.end_fill()

畫豬眼睛

我們定義一個draw_eye()函數(shù)來畫豬眼睛:

def draw_eye():

'''畫眼睛'''

t.color((255, 155, 192), "white")

t.pu()

t.seth(90)

t.fd(-20)

t.seth(0)

t.fd(-95)

t.pd()

t.begin_fill()

t.circle(15)

t.end_fill()

t.color("black")

t.pu()

t.seth(90)

t.fd(12)

t.seth(0)

t.fd(-3)

t.pd()

t.begin_fill()

t.circle(3)

t.end_fill()

t.color((255, 155, 192), "white")

t.pu()

t.seth(90)

t.fd(-25)

t.seth(0)

t.fd(40)

t.pd()

t.begin_fill()

t.circle(15)

t.end_fill()

t.color("black")

t.pu()

t.seth(90)

t.fd(12)

t.seth(0)

t.fd(-3)

t.pd()

t.begin_fill()

t.circle(3)

t.end_fill()

畫臉上的腮紅

我們定義一個draw_face()函數(shù)來畫豬臉上的腮紅:

def draw_face():

''' 畫腮紅'''

t.color((255, 155, 192))

t.pu()

t.seth(90)

t.fd(-95)

t.seth(0)

t.fd(65)

t.pd()

t.begin_fill()

t.circle(30)

t.end_fill()

畫豬嘴

我們定義一個draw_mouth()函數(shù)來畫豬的嘴巴:

def draw_mouth():

'''畫嘴'''

t.color(239, 69, 19)

t.pu()

t.seth(90)

t.fd(15)

t.seth(0)

t.fd(-100)

t.pd()

t.seth(-80)

t.circle(30, 40)

t.circle(40, 80)

畫身體

我們定義一個draw_body()函數(shù)來畫佩奇的身體:

def draw_body():

'''畫身體'''

t.color("red", (218, 56, 247))

t.pu()

t.seth(90)

t.fd(-20)

t.seth(0)

t.fd(-78)

t.pd()

t.begin_fill()

t.seth(-130)

t.circle(100, 10)

t.circle(300, 30)

t.seth(0)

t.fd(230)

t.seth(90)

t.circle(300, 30)

t.circle(100, 3)

t.color((255, 155, 192), (218, 56, 247))

t.seth(-135)

t.circle(-80, 63)

t.circle(-150, 24)

t.end_fill()

畫佩奇的小手

我們定義一個draw_hand()函數(shù)來畫佩奇的小手:

def draw_hand():

'''畫小手'''

t.color((255, 155, 192))

t.pu()

t.seth(90)

t.fd(-40)

t.seth(0)

t.fd(-27)

t.pd()

t.seth(-160)

t.circle(300, 15)

t.pu()

t.seth(90)

t.fd(15)

t.seth(0)

t.fd(0)

t.pd()

t.seth(-10)

t.circle(-20, 90)

t.pu()

t.seth(90)

t.fd(30)

t.seth(0)

t.fd(237)

t.pd()

t.seth(-20)

t.circle(-300, 15)

t.pu()

t.seth(90)

t.fd(20)

t.seth(0)

t.fd(0)

t.pd()

t.seth(-170)

t.circle(20, 90)

畫腳丫

我們定義一個draw_foot()函數(shù)來畫佩奇的腳丫:

def draw_foot():

'''畫腳丫'''

t.pensize(10)

t.color((240, 128, 128))

t.pu()

t.seth(90)

t.fd(-75)

t.seth(0)

t.fd(-180)

t.pd()

t.seth(-90)

t.fd(40)

t.seth(-180)

t.color("black")

t.pensize(15)

t.fd(20)

t.pensize(10)

t.color((240, 128, 128))

t.pu()

t.seth(90)

t.fd(40)

t.seth(0)

t.fd(90)

t.pd()

t.seth(-90)

t.fd(40)

t.seth(-180)

t.color("black")

t.pensize(15)

t.fd(20)

畫尾巴

我們定義一個draw_tail()函數(shù)來畫佩奇的尾巴:

def draw_tail():

'''畫尾巴'''

t.pensize(4)

t.color((255, 155, 192))

t.pu()

t.seth(90)

t.fd(70)

t.seth(0)

t.fd(95)

t.pd()

t.seth(0)

t.circle(70, 20)

t.circle(10, 330)

t.circle(70, 30)

t.exitonclick()

主函數(shù)main()

我們先設(shè)置畫筆的大小,設(shè)置隱藏位置小海龜,設(shè)置顏色模式,設(shè)置像素大小,設(shè)置速度,然后就可以愉快的花花了。

def main():

"""主函數(shù)"""

t.pensize(4)

t.hideturtle()

t.colormode(255)

t.color((255, 155, 192), "pink")

t.setup(840, 500)

t.title('可愛的小豬佩奇')

t.speed(20)

draw_nose()

draw_head()

draw_ear()

draw_eye()

draw_face()

draw_mouth()

draw_body()

draw_hand()

draw_foot()

draw_tail()

總結(jié)

以上是生活随笔為你收集整理的python画圆形螺旋线_宝宝爱看小猪佩奇,很简单,让我们用python搞定它的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。