python海龟作图画爱心_用python的turtle,画爱心,表白,求婚完整代码,海龟作图创意...
import turtle
import time
# 实现清屏
def clear_screen():
turtle.penup() #画笔抬起
turtle.goto(0,0) #定位到(0,0)
turtle.color('white')
turtle.pensize(800) #画笔粗细
turtle.pendown() #画笔落下
turtle.setheading(0) #设置朝向
turtle.fd(300) #前进
turtle.bk(600) #后退
# 初始化海龟的位置
def go_start(x, y, state):
turtle.pendown() if state else turtle.penup()
turtle.goto(x, y)
#画线,state为真时海龟回到原点,为假时不回到原来的出发点
def draw_line(length, angle, state):
turtle.pensize(1)
turtle.pendown()
turtle.setheading(angle)
turtle.fd(length)
turtle.bk(length) if state else turtle.penup()
turtle.penup()
# 画出发射爱心的小人
def draw_people(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.pensize(2)
turtle.color('black')
turtle.setheading(0)
turtle.circle(35, 360)
turtle.penup()
turtle.pensize(3)
turtle.setheading(90)
turtle.fd(45)
turtle.setheading(180)
turtle.fd(20)
turtle.setheading(0)
turtle.fd(35)
turtle.pendown()
turtle.circle(4, 360)
turtle.penup()
turtle.goto(x, y)
turtle.pensize(2)
turtle.setheading(0)
turtle.fd(20)
turtle.setheading(90)
turtle.fd(20)
turtle.setheading(-90)
turtle.pendown()
turtle.circle(5, 180)
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 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 draw_feather(size):
angle = 30 # 箭的倾角
feather_num = size // 6 # 羽毛的数量
feather_length = size // 3 # 羽毛的长度
feather_gap = size // 10 # 羽毛的间隔
for i in range(feather_num):
draw_line(feather_gap, angle + 180, False) # 箭柄,不折返
draw_line(feather_length, angle + 145, True) # 羽翼,要折返
draw_line(feather_length, angle + 145, False)
draw_line(feather_num * feather_gap, angle, False)
draw_line(feather_length, angle + 145 + 180, False)
for i in range(feather_num):
draw_line(feather_gap, angle + 180, False) # 箭柄,不折返
draw_line(feather_length, angle - 145, True) # 羽翼,要折返
draw_line(feather_length, angle - 145, False)
draw_line(feather_num * feather_gap, angle, False)
draw_line(feather_length, angle - 145 + 180, False)
# 画一箭穿心,最后箭的头没有画出来,用海龟来代替
def arrow_heart(x, y, size):
go_start(x, y, False)
draw_heart(size * 1.15)
turtle.setheading(-150)
turtle.penup()
turtle.fd(size * 2.2)
draw_heart(size)
turtle.penup()
turtle.setheading(150)
turtle.fd(size * 2.2)
turtle.color('black')
draw_feather(size)
turtle.pensize(4)
turtle.setheading(30)
turtle.pendown()
turtle.fd(size * 2)
turtle.penup()
turtle.setheading(29)
turtle.fd(size * 5.7)
turtle.color('black')
turtle.pensize(4)
turtle.pendown()
turtle.fd(size * 1.2)
#显示倒数3,2,1
def draw_0(i):
turtle.speed(0)
turtle.penup()
turtle.hideturtle() # 隐藏箭头显示
turtle.goto(-50, -100)
turtle.color('red')
write = turtle.write(i, font=('宋体', 200, 'normal'))
time.sleep(1)
# 显示文字
def draw_1():
turtle.penup()
turtle.hideturtle() #隐藏箭头显示
turtle.goto(-250, 0)
turtle.color('red')
write = turtle.write('臭猪猪,接招', font=('宋体', 60, 'normal'))
time.sleep(2)
# 显示发射爱心的小人儿
def draw_2():
turtle.speed(3)
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(205, -100)
draw_heart(43)
turtle.hideturtle()
time.sleep(2)
def draw_3():
turtle.penup()
turtle.hideturtle() # 隐藏箭头显示
turtle.goto(-220, 50)
turtle.color('red')
write = turtle.write('
python海龟作图画爱心_用python的turtle,画爱心,表白,求婚完整代码,海龟作图创意...相关推荐
- 用python画爱心写一句话_python中用turtle画爱心表白
python中用turtle画爱心表白python 运行后的效果图:ide 下面的代码是在python3.7写的,代码有点长,但却语法简单易懂动画 代码以下:orm import turtle str ...
- python 海龟turtle画爱心
初学python,第一次尝试使用turtle画爱心- 这是画出来的效果 这是我的代码 import turtle turtle.pensize(5) turtle.pencolor("red ...
- python中用turtle画爱心表白
python中用turtle画爱心表白 运行后的效果图: 下面的代码是在python3.7写的,代码有点长,但却语法简单易懂 代码如下: import turtle str = input('请输入表 ...
- python绘制爱心气球_python中用turtle画爱心表白-Go语言中文社区
python中用turtle画爱心表白 运行后的效果图: 下面的代码是在python3.7写的,代码有点长,但却语法简单易懂 代码如下: import turtle str = input('请输入表 ...
- python turtle画爱心的代码_Python|用turtle画笔画爱心
欢迎点击「算法与编程之美」↑关注我们! 本文首发于微信公众号:"算法与编程之美",欢迎关注,及时了解更多此系列文章. 问题描述 Turtle是python中的一种可视化工具库,可以 ...
- python创建画布的函数_使用Python的turtle(海龟)模块画图
第一步:让Python引入turtle模块,引入模块就是告诉Python你想要用它. import turtle 第二步:创建画布.调用turtle中的Pen函数 t = turtle.Pen() 第 ...
- python图画制作_用python绘画一些简单图片
python画笑脸 程序源代码 import turtle #画脸 t = turtle.Pen() t.speed(15) #t.circle(150) #t.color('orange') t.f ...
- python做审计底稿视频_最新Python教学视频,每天自学俩小时,让你offer拿到手软...
2020最新Python零基础到精通资料教材,干货分享,新基础Python教材,看这里,这里有你想要的所有资源哦,最强笔记,教你怎么入门提升!让你对自己更加有信心,重点是资料都是免费的,免费!!! 如 ...
- python socket清空接受区_用Python制作只属于你和ta的聊天渠道吧
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: Python应用宝典 PS:如有需要Python学习资料的小伙伴可 ...
最新文章
- Mybatis知识(4)
- 4.Android loader详解___回调
- [YTU]_2865( 结构体--日期计算)
- Siamese Network (应用篇4) :块匹配中一致性特征和距离测度学习 CVPR2015
- c语言程序设计江宝钏第九章,C语言程序设计 (江宝钏 著) 清华大学出版社 第9章习题答案1...
- MariaDB mysql 比较区别 选择
- .Net Core 全局配置读取管理方法 ConfigurationManager
- 跨平台的.NET邮件协议MailKit组件解析
- scanf( )函数的返回值
- python123第一周测试作业指导书_风速仪作业指导书.doc
- 野生前端的数据结构基础练习(4)——字典
- ((CTRL-CHAR,code 8)) : only regular white space is allowed between tokens
- 智能手表发展史:我们用过、见过和从未听说的
- intel 新一代集成显卡
- 韦仕敦大学计算机科学,2020年西安大略大学有哪些优势专业
- 【概率图与随机过程】25 从有向到无向:谈谈条件随机场
- python 企查查爬虫_python爬虫另辟蹊径绕过企查查的登录验证,我太冇财了
- 投影仪用光学引擎行业现状调研及趋势分析报告
- 【转】Python之获取每日涨停板股票数据并绘制K线图!
- SpringBoot核心注解