Python制作七夕表白实例项目-让你的情人心动起来_python-项目-浪漫爱心表白-设计流程图(3)

2.2.4、画出人物
# 画出人物
def draw\_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、画爱心
# 画爱心
def draw\_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、主函数
def Main():
    turtle.setup(900, 500)
    paintingOne()
    clear_all()

    paintingTwo()
    clear_all()

    turtle.done()

2.2.7、调用主函数
if __name__ == '\_\_main\_\_':
    Main()

2.3、代码文件


import turtle
import time
 
 
# 清屏函数
def clear\_all():
    turtle.penup()
    turtle.goto(0, 0)
    turtle.color('white')
    turtle.pensize(800)
    turtle.pendown()
    turtle.setheading(0)
    turtle.fd(300)
    turtle.bk(600)
 
 
# 重定位海龟的位置
def go\_to(x, y, state):
    turtle.pendown() if state else turtle.penup()
    turtle.goto(x, y)

# 画爱心
def draw\_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()


# 第一个画面,显示文字
def paintingOne():
    turtle.penup()
    turtle.goto(-300, 0)
    turtle.color('pink')
    turtle.write('时光让我们相遇,我的情人,七夕快乐!!!', font=('楷体', 24, 'normal'))
    time.sleep(3)

 
# 画出人物
def draw\_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()



# 第二个画面,显示发射爱心的小人
def paintingTwo():
    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)

    turtle.penup()
    turtle.goto(250, -100)

    draw_heart(45)

    turtle.hideturtle()
    time.sleep(1)

 


![img](https://img-blog.csdnimg.cn/img_convert/473a105b253dd626ec968120ea6984ba.png)
![img](https://img-blog.csdnimg.cn/img_convert/66c59144176a0fcc5622d1c37b123d76.png)

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

04)]
[外链图片转存中...(img-6eL3QRnj-1714707848905)]

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值