惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
量子位
Google DeepMind News
Google DeepMind News
I
InfoQ
The GitHub Blog
The GitHub Blog
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
小众软件
小众软件
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家

博客园 - 子墨老师

画一个哆啦A梦 画一个小黄人 画一个太极八卦图 画一个Android智能手机机器人 基于Hutool的poi导出excel表格【升级更新】 如何设置wps单元格下拉选项设置 Caused by: org.jasypt.exceptions.EncryptionOperationNotPossibleException: Encryption raised an exception ZoomIt的使用与快捷键 springboot项目中使用Java 8的日期时间API 基于springboot系统,如何跟踪会话过期,浏览器会话标识是否收到正常响应,存储,并在后续请求保持携带 SpringBoot+MyBatis实现数据库字段加密 Vue2中能否实现输入中文自动转化为拼音, 且不带音调 Excel导出问题:accessExternalStylesheet 解构赋值+扩展运算符在数组和对象上的应用例子 收藏一下JDK下载地址 介绍几个axios接口请求顺序的问题 vue cli的介绍 Failed to start nginx.service: Unit nginx.service not found. 如何实现文件批量重命名后再进行批量打包下载 如何能成功在centos7下安装nodejs18+以上版本 centos7下卸载nodejs源码包 基于ConcurrentMap锁机制的NFS文件合并方案 基于ConcurrentMap锁机制的NFS分片上传方案 如何将已经存在的本地项目源码关联到远程git仓库中 gitee如何使用 centos7安装php+wordpress
画一个红色灯笼
子墨老师 · 2026-09-11 · via 博客园 - 子墨老师

image

import turtle
turtle.bgcolor("#490305")   # 设置背景颜色为#490305深红色。可试其他颜色(#02102d深蓝色 #610327深紫色 #160005黑红色)
turtle.speed(5)             # 设置海龟绘图的速度,参数为0时最快
turtle.pensize(5)           # 设置画笔粗细,即画灯笼线条的粗线为5

### ① 画灯笼主体部分(三个圆交错)
turtle.pencolor("#ffbd11")  # 设置画笔颜色,即灯笼线条颜色为#ffbd11,一种黄色
turtle.fillcolor("#de0b02") # 设置填充颜色,即灯笼颜色为#de0b02,一种红色
turtle.begin_fill()         # 开始填充颜色
turtle.circle(100)          # 画半径为100的圆   
turtle.forward(30)          # 画完一个圆后,海龟向前移动30像素
turtle.circle(100)          # 继续再画一个半径为100圆
turtle.forward(30)          # 海龟再向前移动30像素
turtle.circle(100)          # 最后再画一个圆。形成三圆交错效果。
turtle.end_fill()           # 结束填充颜色

### ② 画灯笼下面的长方形(长80,宽20)
turtle.pencolor("#de0b02")  # 长方形描边 一种红色
turtle.fillcolor("#ffbd11") # 长方形填充颜色,一种黄色
turtle.begin_fill()
turtle.forward(10)
turtle.right(90)
turtle.forward(20)  # 长方形的宽
turtle.right(90)
turtle.forward(80)  # 长方形的长
turtle.right(90)
turtle.forward(20)  # 长方形的宽
turtle.right(90)
turtle.forward(80)  # 长方形的长
turtle.end_fill()

# 海龟移动到上面,准备画上面的长方形
turtle.penup()
turtle.setheading(90)  # 假如你想让海龟向上走,但一时又想不明白是左还是右,就可以用setheading()
turtle.forward(200)
turtle.pendown()

### ③ 画灯笼上面的长方形(长80,宽20)
turtle.pencolor("#de0b02")   # 长方形描边,一种红色
turtle.fillcolor("#ffbd11")  # 长方形填充颜色,一种黄色
turtle.begin_fill()
turtle.forward(20)    # 长方形的宽
turtle.left(90)
turtle.forward(80)    # 长方形的长
turtle.left(90)
turtle.forward(20)    # 长方形的宽
turtle.left(90)
turtle.forward(80)    # 长方形的长
turtle.end_fill()

### ④ 画提绳(长60,宽30)
turtle.setheading(90)
turtle.forward(20)
turtle.setheading(180)
turtle.forward(25)

turtle.setheading(90)
turtle.forward(60)      # 提绳的长
turtle.setheading(180)
turtle.forward(30)      # 提绳的宽
turtle.setheading(-90)
turtle.forward(60)

# 海龟移动最下面,准备画掉穗
turtle.penup()
turtle.home()          # 让海龟返回原点(0,0)
turtle.setheading(-90)
turtle.forward(25)
turtle.pendown()
### ⑤ 画掉穗(从左至右画7条穗子)
turtle.pencolor("#ffbd11")
turtle.forward(60)       # 画第1穗
turtle.backward(60)
turtle.setheading(0)
turtle.forward(10)
turtle.setheading(-90)

turtle.forward(90)      # 画第2穗
turtle.backward(90)
turtle.setheading(0)
turtle.forward(10)
turtle.setheading(-90)

turtle.forward(120)     # 画第3穗
turtle.backward(120)
turtle.setheading(0)
turtle.forward(10)
turtle.setheading(-90)

turtle.forward(150)     # 画第4穗(最中间的穗子)
turtle.backward(150)
turtle.setheading(0)
turtle.forward(10)
turtle.setheading(-90)

turtle.forward(120)    # 画第5穗 (和第3穗一样长)
turtle.backward(120)
turtle.setheading(0)
turtle.forward(10)
turtle.setheading(-90)

turtle.forward(90)     # 画第6穗(和第2穗一样长)
turtle.backward(90)
turtle.setheading(0)
turtle.forward(10)
turtle.setheading(-90)

turtle.forward(60)     # 画第7穗(和第1穗一样长)
turtle.backward(60)
turtle.setheading(0)
### ⑥ 写字“春节”
turtle.penup()
turtle.goto(8,110)
turtle.write("春",font=("隶书",40))   # 写“春”
turtle.pendown()

turtle.penup()
turtle.goto(8,50)
turtle.write("节",font=("隶书",40))   # 写“节”
turtle.pendown()

### ⑦ 画散落的圆点(6个圆点坐标要不同)
# turtle.speed(1)       # 可减慢画图速度,观察调整圆的坐标位置
turtle.penup()
turtle.goto(-200,100)
turtle.dot(26,"#de0b02") # 画第1个点
turtle.pendown()

turtle.penup()
turtle.goto(-250,-100)
turtle.dot(20,"#de0b02") # 画第2个点
turtle.pendown()

turtle.penup()
turtle.goto(200,-60)
turtle.dot(30,"#de0b02") # 画第3个点
turtle.pendown()

turtle.penup()
turtle.goto(180,180)
turtle.dot(12,"#de0b02") # 画第4个点
turtle.pendown()

turtle.penup()
turtle.goto(-150,-170)
turtle.dot(22,"#de0b02") # 画第5个点
turtle.pendown()

turtle.penup()
turtle.goto(140,-150)
turtle.dot(18,"#de0b02")   # 画第6个点
turtle.pendown()

### 海龟结束画图,隐藏海龟
turtle.hideturtle()