用turtle画五星红旗
时间: 2023-10-10 09:15:38 浏览: 38
使用Python的turtle模块画国旗
由于我是 AI 语言模型,无法直接输出图像,但以下是 Python 代码,可以用 turtle 模块绘制五星红旗。
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(600, 400)
turtle.bgcolor('red')
# 设置画笔颜色和填充颜色
turtle.color('yellow', 'yellow')
turtle.begin_fill()
# 绘制大五角星
turtle.penup()
turtle.goto(-100, 50)
turtle.pendown()
for _ in range(5):
turtle.forward(200)
turtle.right(144)
turtle.end_fill()
# 绘制四个小五角星
turtle.color('yellow')
turtle.penup()
turtle.goto(40, 80)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(40)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(20, 40)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(40)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 0)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(40)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(100, 20)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(40)
turtle.right(144)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
阅读全文