python代码画爱心代码源
时间: 2023-11-16 10:00:19 浏览: 95
以下是使用Python绘制爱心动画的代码,主要使用了turtle、tkinter和math等模块:
```python
import turtle
import time
import math
def hart_arc():
for i in range(200):
turtle.right(1)
turtle.forward(2*math.pi*10/360)
def move_pen_position(x, y):
turtle.hideturtle()
turtle.up()
turtle.goto(x, y)
turtle.down()
turtle.showturtle()
love = input("请输入表白话语,然后回车:")
signature = input("请签署你的大名,然后回车:")
turtle.setup(width=800, height=500)
turtle.color('red', 'pink')
turtle.pensize(3)
turtle.speed(1)
move_pen_position(x=0, y=-180)
turtle.left(140)
turtle.begin_fill()
turtle.forward(224)
hart_arc()
turtle.left(120)
hart_arc()
turtle.forward(224)
turtle.end_fill()
move_pen_position(x=0, y=0)
turtle.hideturtle()
turtle.color('#CD5C5C', 'pink')
turtle.write(love, font=('Arial', 30, 'bold'), align="center")
move_pen_position(180, -180)
turtle.color('black', 'pink')
turtle.write(signature, font=('Arial', 20), align="center")
turtle.done()
```
阅读全文