Python制作七夕表白案例分享_第1頁
Python制作七夕表白案例分享_第2頁
Python制作七夕表白案例分享_第3頁
Python制作七夕表白案例分享_第4頁
Python制作七夕表白案例分享_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

第Python制作七夕表白案例分享目錄一、記錄一起走過的那些日子二、創(chuàng)意代碼表白2.1、效果演示2.2、制作步過程2.2.1、清屏函數(shù)2.2.2、重定位海龜?shù)奈恢?.2.3、顯示文字2.2.4、畫出人物2.2.5、畫愛心2.2.6、主函數(shù)2.2.7、調(diào)用主函數(shù)2.3、代碼文件

一、記錄一起走過的那些日子

講述和親愛的TA一起經(jīng)歷的那些故事

那些初見印象那些浪漫的開始那些銘記于心的大小事那些經(jīng)歷的曲折那些經(jīng)歷的幸福與快樂那些珍貴的瞬間那些對未來的期許/計劃

二、創(chuàng)意代碼表白

以程序員的方式撒狗糧,專業(yè)浪漫,值得擁有!

2.1、效果演示

1、顯示表白文字

2、顯示人物和愛心

2.2、制作步過程

主要是編寫如下的幾個函數(shù),來實現(xiàn)七夕表白的功能。

2.2.1、清屏函數(shù)

#清屏函數(shù)

defclear_all():

turtle.penup()

turtle.goto(0,0)

turtle.color('white')

turtle.pensize(800)

turtle.pendown()

turtle.setheading(0)

turtle.fd(300)

turtle.bk(600)

2.2.2、重定位海龜?shù)奈恢?/p>

#重定位海龜?shù)奈恢?/p>

defgo_to(x,y,state):

turtle.pendown()ifstateelseturtle.penup()

turtle.goto(x,y)

2.2.3、顯示文字

#第一個畫面,顯示文字

defpaintingOne():

turtle.penup()

turtle.goto(-300,0)

turtle.color('pink')

turtle.write('時光讓我們相遇,我的情人,七夕快樂?。。?,font=('楷體',24,'normal'))

time.sleep(3)

2.2.4、畫出人物

#畫出人物

defdraw_people(x,y):

turtle.penup()

turtle.goto(x,y)

turtle.pendown()

turtle.pensize(2)

turtle.color('pink')

turtle.setheading(0)

turtle.circle(60,360)

turtle.penup()

turtle.setheading(90)

turtle.fd(75)

turtle.setheading(180)

turtle.fd(20)

turtle.pensize(4)

turtle.pendown()

turtle.circle(2,360)

turtle.setheading(0)

turtle.penup()

turtle.fd(40)

turtle.pensize(4)

turtle.pendown()

turtle.circle(-2,360)

turtle.penup()

turtle.goto(x,y)

turtle.setheading(-90)

turtle.pendown()

turtle.fd(20)

turtle.setheading(0)

turtle.fd(35)

turtle.setheading(60)

turtle.fd(10)

turtle.penup()

turtle.goto(x,y)

turtle.setheading(-90)

turtle.pendown()

turtle.fd(40)

turtle.setheading(0)

turtle.fd(35)

turtle.setheading(-60)

turtle.fd(10)

turtle.penup()

turtle.goto(x,y)

turtle.setheading(-90)

turtle.pendown()

turtle.fd(60)

turtle.setheading(-135)

turtle.fd(60)

turtle.bk(60)

turtle.setheading(-45)

turtle.fd(30)

turtle.setheading(-135)

turtle.fd(35)

turtle.penup()

2.2.5、畫愛心

#畫愛心

defdraw_heart(size):

turtle.color('red','pink')

turtle.pensize(2)

turtle.pendown()

turtle.setheading(150)

turtle.begin_fill()

turtle.fd(size)

turtle.circle(size*-3.745,45)

turtle.circle(size*-1.431,165)

turtle.left(120)

turtle.circle(size*-1.431,165)

turtle.circle(size*-3.745,45)

turtle.fd(size)

turtle.end_fill()

2.2.6、主函數(shù)

defMain():

turtle.setup(900,500)

paintingOne()

clear_all()

paintingTwo()

clear_all()

turtle.done()

2.2.7、調(diào)用主函數(shù)

if__name__=='__main__':

Main()

2.3、代碼文件

importturtle

importtime

#清屏函數(shù)

defclear_all():

turtle.penup()

turtle.goto(0,0)

turtle.color('white')

turtle.pensize(800)

turtle.pendown()

turtle.setheading(0)

turtle.fd(300)

turtle.bk(600)

#重定位海龜?shù)奈恢?/p>

defgo_to(x,y,state):

turtle.pendown()ifstateelseturtle.penup()

turtle.goto(x,y)

#畫愛心

defdraw_heart(size):

turtle.color('red','pink')

turtle.pensize(2)

turtle.pendown()

turtle.setheading(150)

turtle.begin_fill()

turtle.fd(size)

turtle.circle(size*-3.745,45)

turtle.circle(size*-1.431,165)

turtle.left(120)

turtle.circle(size*-1.431,165)

turtle.circle(size*-3.745,45)

turtle.fd(size)

turtle.end_fill()

#第一個畫面,顯示文字

defpaintingOne():

turtle.penup()

turtle.goto(-300,0)

turtle.color('pink')

turtle.write('時光讓我們相遇,我的情人,七夕快樂?。?!',font=('楷體',24,'normal'))

time.sleep(3)

#畫出人物

defdraw_people(x,y):

turtle.penup()

turtle.goto(x,y)

turtle.pendown()

turtle.pensize(2)

turtle.color('pink')

turtle.setheading(0)

turtle.circle(60,360)

turtle.penup()

turtle.setheading(90)

turtle.fd(75)

turtle.setheading(180)

turtle.fd(20)

turtle.pensize(4)

turtle.pendown()

turtle.circle(2,360)

turtle.setheading(0)

turtle.penup()

turtle.fd(40)

turtle.pensize(4)

turtle.pendown()

turtle.circle(-2,360)

turtle.penup()

turtle.goto(x,y)

turtle.setheading(-90)

turtle.pendown()

turtle.fd(20)

turtle.setheading(0)

turtle.fd(35)

turtle.setheading(60)

turtle.fd(10)

turtle.penup()

turtle.goto(x,y)

turtle.setheading(-90)

turtle.pendown()

turtle.fd(40)

turtle.setheading(0)

turtle.fd(35)

turtle.setheading(-60)

turtle.fd(10)

turtle.penup()

turtle.goto(x,y)

turtle.setheading(-90)

turtle.pendown()

turtle.fd(60)

turtle.setheading(-135)

turtle.fd(60)

turtle.bk(60)

turtle.setheading(-45)

turtle.fd(30)

turtle.setheading(-135)

turtle.fd(35)

turtle.penup()

#第二個畫面,顯示發(fā)射愛心的小人

defpaintingTwo():

turtle.speed(10)

draw_people(-250,20)

turtle.penup()

turtle.goto(-150,-30)

draw_heart(14)

turtle.penup()

turtle.goto(-20,-60)

draw_heart(25)

t

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論