turtle绘图一个飘扬的五星红旗
时间: 2024-04-20 13:18:40 浏览: 111
飘动的红旗
4星 · 用户满意度95%
以下是使用Python turtle库绘制飘扬的五星红旗的代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 设置画笔速度
turtle.speed(10)
# 设置画笔颜色
turtle.color('red')
# 绘制红旗
turtle.begin_fill()
turtle.penup()
turtle.goto(-300, 200)
turtle.pendown()
turtle.forward(600)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.forward(600)
turtle.right(90)
turtle.forward(400)
turtle.end_fill()
# 绘制大星星
turtle.color('yellow')
turtle.penup()
turtle.goto(-220, 160)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
# 绘制四个小星星
turtle.penup()
turtle.goto(-100, 180)
turtle.setheading(305)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(20)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-80, 130)
turtle.setheading(30)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(20)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-80, 80)
turtle.setheading(5)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(20)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-100, 30)
turtle.setheading(280)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(20)
turtle.right(144)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
阅读全文