本文讲述了python爱心表白代码制作!具有很好的参考价值,希望对大家有所帮助。一起跟随六星小编过来看看吧,具体如下:
爱心表白:君初相识,犹如故人归。天涯明月新,朝暮最相思
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编程语言,推荐大家关注一个微信公众号:Python编程学习圈。每天分享行业资讯、技术干货供大家阅读,关注即可免费领取整套Python入门到进阶的学习资料以及教程,感兴趣的小伙伴赶紧行动起来吧。
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!