怎么用Python turtle绘制中国结
发表于:2025-02-04 作者:千家信息网编辑
千家信息网最后更新 2025年02月04日,这篇文章主要介绍"怎么用Python turtle绘制中国结",在日常操作中,相信很多人在怎么用Python turtle绘制中国结问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对
千家信息网最后更新 2025年02月04日怎么用Python turtle绘制中国结
这篇文章主要介绍"怎么用Python turtle绘制中国结",在日常操作中,相信很多人在怎么用Python turtle绘制中国结问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"怎么用Python turtle绘制中国结"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
一、中国结 01 平安喜乐
1)效果图
2)附代码
import turtleturtle.screensize(600,800)turtle.pensize(10)turtle.pencolor("red")turtle.seth(-45)turtle.fd(102)turtle.circle(-6,180)turtle.fd(102)turtle.circle(6,180)turtle.fd(102)turtle.circle(-6,180)turtle.fd(102)turtle.circle(6,180)turtle.fd(102)turtle.circle(-6,180)turtle.fd(102)turtle.circle(6,180)turtle.fd(92)turtle.circle(-6,270)turtle.fd(92)turtle.circle(6,180)turtle.fd(102)turtle.circle(-6,180)turtle.fd(102)turtle.circle(6,180)turtle.fd(102)turtle.circle(-6,180)turtle.fd(102)turtle.circle(6,180)turtle.fd(102)turtle.circle(-6,180)turtle.fd(88)turtle.fd(20)turtle.seth(135)turtle.fd(20)turtle.seth(225)turtle.fd(20)turtle.seth(315)turtle.fd(20)turtle.seth(45)turtle.fd(20)turtle.seth(135)turtle.begin_fill()turtle.fillcolor("red")turtle.fd(50)turtle.seth(45)turtle.fd(30)turtle.seth(-45)turtle.fd(30)turtle.seth(225)turtle.fd(30)turtle.end_fill()turtle.seth(90)turtle.fd(40)turtle.pensize(20)turtle.fd(10)turtle.pensize(5)turtle.seth(105)turtle.fd(30)turtle.circle(-8,240)turtle.circle(20,20)turtle.fd(5)turtle.circle(20,60)turtle.fd(25)turtle.penup()turtle.setx(0)turtle.sety(0)turtle.goto(2,-127)turtle.pendown()turtle.pensize(5)turtle.begin_fill()turtle.fillcolor("red")turtle.seth(0)turtle.fd(15)turtle.seth(-90)turtle.fd(10)turtle.seth(180)turtle.fd(15)turtle.seth(90)turtle.fd(10)turtle.seth(0)turtle.fd(15)turtle.end_fill()turtle.pensize(2)for x in range(6): turtle.seth(-90) turtle.fd(50) turtle.penup() turtle.seth(90) turtle.fd(50) turtle.seth(180) turtle.fd(3) turtle.pendown()
二、中国结 02 心想事成
1)效果图
2)附代码
import turtle as tdef goto(x,y): t.penup() t.goto(x,y) t.pendown() def init(): t.setup(800,800) t.pensize(10) t.pencolor("red") t.speed(14) def jiexin(): m,n=0,200 for i in range(11): goto(m,n) t.seth(-45) t.fd(200) m-=20/pow(2,0.5) n-=20/pow(2,0.5) m,n=0,200 for j in range(11): goto(m,n) t.seth(-135) t.fd(200) m+=20/pow(2,0.5) n-=20/pow(2,0.5) def jiexiaoban(): m=-20/pow(2,0.5) n=200-20/pow(2,0.5) for k in range(4): goto(m,n) t.seth(135) t.fd(20) t.circle(10,180) t.fd(20) m-=40/pow(2,0.5) n-=40/pow(2,0.5) m=20/pow(2,0.5) n=200-20/pow(2,0.5) for k in range(4): goto(m,n) t.seth(45) t.fd(20) t.circle(-10,180) t.fd(20) m+=40/pow(2,0.5) n-=40/pow(2,0.5) m=20/pow(2,0.5) n=200-200*pow(2,0.5)+20/pow(2,0.5) for k in range(4): goto(m,n) t.seth(-45) t.fd(20) t.circle(10,180) t.fd(20) m+=40/pow(2,0.5) n+=40/pow(2,0.5) m=-20/pow(2,0.5) n=200-200*pow(2,0.5)+20/pow(2,0.5) for k in range(4): goto(m,n) t.seth(-135) t.fd(20) t.circle(-10,180) t.fd(20) m-=40/pow(2,0.5) n+=40/pow(2,0.5) def waiyuan(): goto(90*pow(2,0.5),200-110*pow(2,0.5)) t.seth(-45) t.circle(20,270) goto(-90*pow(2,0.5),200-110*pow(2,0.5)) t.seth(-135) t.circle(-20,270) goto(80*pow(2,0.5),200-120*pow(2,0.5)) t.seth(-45) t.circle(40,270) goto(-80*pow(2,0.5),200-120*pow(2,0.5)) t.seth(-135) t.circle(-40,270) def shengzi(): goto(0,200) t.pensize(20) t.seth(90) t.fd(60) goto(0,320) t.pensize(12) t.seth(180) t.circle(30,360) goto(0,200-200*pow(2,0.5)) t.pensize(40) t.seth(-90) t.fd(20) t.pensize(2) s=-20 for i in range(11): goto(s,200-200*pow(2,0.5)) t.seth(-90) t.fd(200) s+=4 def hanzi(): goto(-150,325) t.write("幸福中国结",font=("Arial",40,"normal")) def main(): init() jiexin() jiexiaoban() waiyuan() shengzi() hanzi() t.hideturtle()
三、中国结 03 烟火年年
辞慕尔尔,烟火年年,前程似锦,顺遂康安。
到此,关于"怎么用Python turtle绘制中国结"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
中国
中国结
学习
代码
效果
效果图
更多
烟火
帮助
喜乐
实用
顺遂
幸福
心想事成
接下来
前程
前程似锦
文章
方法
理论
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
阿里云 数据库产品
外接固态硬盘拷贝数据库
网络安全讨论查找问题隐患
软件开发公司销售人员看的书
腾讯代理服务器
网络安全设计的重要性
计算机和网络技术基础差
宾夕法尼亚大学经济发展数据库
计算机三级网络技术下载教程
软件开发管理能力陷阱
网络安全培训的名校
南京软件开发价格实惠
营销软件开发商家咨询热线
九运做软件开发有发展前景吗
青岛学习网络技术
如何让数据库自己加的数据
山西养老软件开发
计算机网络技术和黑客
软件开发 施工 验收签证
html与sql数据库
如何选择有公网ip服务器
想学网络技术选择什么职业学院
dnf登录后黑屏一直连接服务器
蜗牛软件开发适合零基础吗
裸金属服务器操作系统安装
服务器还原电脑后
街道网络安全会议记录内容
花雨庭服务器生存服怎么刷物资
关于网络安全有什么
软件开发 mcu