這篇文章將為大家詳細講解有關Python如何制作表白愛心合集,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
一、愛心表白:做我女朋友吧,行就行,不行我再想想辦法
1)效果展示
2)附主程序
t=turtle.pen() t=turtle t.up() t.goto(0,150) t.down() t.color('pink') t.begin_fill() t.fillcolor('pink') t.speed(1) t.left(45) t.forward(150) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(250+math.sqrt(2)*100) t.right (90) t.speed(2) t.forward(250+100*math.sqrt(2)) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(150) t.end_fill() t.goto(-10,0) t.pencolor('white') #L t.pensize(10) t.goto(-50,0) t.goto(-50,80) t.up () #I t.goto(-100,0) t.down() t.goto(-160,0) t.goto(-130,0) t.goto(-130,80) t.goto(-160,80) t.goto(-100,80) t.up() #O t.goto(10,25) t.down() t.right(45) t.circle(25,extent=180) t.goto(60,55) t.circle(25,extent=180) t.goto(10,25) t.up() t.goto(75,80) t.down() t.goto(100,0) t.goto(125,80) t.up() t.goto(180,80) t.down() t.goto(140,80) t.goto(140,0) t.goto(180,0) t.up() t.goto(180,40) t.down() t.goto(140,40) #U t.up() t.goto(-40,-30) t.down() t.goto(-40,-80) t.circle(40,extent=180) t.goto(40,-30) t.hideturtle() a=input()
二、愛心表白:????有兩個心愿:你在身邊,在你身邊
1)效果展示
2)附主程序
pen = turtle.Turtle() pen.hideturtle() pen.fillcolor('pink') pen.begin_fill() # set the starting direction pen.left(110) # draw the left bottom part while pen.heading() < 140: # rotate & forward pen.left(1) pen.forward(2) # move up pen.forward(90) # draw the left upper part while pen.xcor() < 0: pen.right(0.8) pen.forward(1) # go back to the starting point, and do the right part as a mirror pen.up() pen.goto(0, 0) pen.down() # set the direction pen.setheading(70) # draw the right bottom part while pen.heading() > 40: # Defining step by step curve motion pen.right(1) pen.forward(2) # move up pen.forward(90) # draw the right upper part while pen.xcor() > 0: print(pen.xcor()) pen.left(0.8) pen.forward(1) # Ending the filling of the color pen.end_fill()
三、愛心表白:君初相識,猶如故人歸。天涯明月新,朝暮最相思
1)效果展示
2)附主程序
import turtle as t def heart(x,y,z): # 繪制愛心 t.pensize(2) t.pencolor("black") if z == 1: t.fillcolor("red") elif z == 0: t.fillcolor("pink") t.begin_fill() #左半邊 t.penup() t.goto(x,y) t.pendown() t.circle(50,180) t.circle(180,37) t.left(46) #右半邊 t.circle(180,37) t.circle(50, 182) t.end_fill() def arrow1(x,y): t.pensize(5) t.pencolor("black") t.fillcolor("brown") t.penup() t.goto(x, y) t.pendown() t.setheading(210) t.forward(150) t.begin_fill() t.left(30) t.forward(20) t.right(30) t.forward(50) t.right(150) t.forward(20) t.left(120) t.forward(20) t.right(150) t.forward(50) t.right(30) t.forward(20) t.end_fill() def arrow2(x, y): t.pensize(5) t.pencolor("black") t.fillcolor("brown") t.penup() t.goto(x, y) t.pendown() t.begin_fill() t.setheading(30) t.forward(100) t.left(90) t.forward(8) t.right(120) t.forward(16) t.right(120) t.forward(16) t.right(120) t.forward(8) t.end_fill() def main(): t.setheading(90) heart(50, 130, 0) t.setheading(120) heart(0, 100, 1) arrow1(-20, 60) arrow2(100, 130) t.hideturtle() t.exitonclick()
關于“Python如何制作表白愛心合集”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。