turtle画五星红旗
时间: 2023-10-10 21:13:50 浏览: 207
以下是使用Python中的turtle库绘制五星红旗的代码:
```
import turtle
# 设置画布大小和背景色
turtle.setup(800, 600)
turtle.bgcolor('#DE2910')
# 绘制大五角星
turtle.penup()
turtle.goto(-200, 100)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(300)
turtle.right(144)
turtle.end_fill()
# 绘制四个小五角星
turtle.penup()
turtle.goto(-90, 180)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(60)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-60, 70)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(60)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 70)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(60)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(90, 180)
turtle.pendown()
turtle.begin_fill()
for _ in range(5):
turtle.forward(60)
turtle.right(144)
turtle.end_fill()
# 隐藏画笔,完成绘制
turtle.hideturtle()
turtle.done()
```
运行以上代码,即可在turtle画布上绘制出五星红旗。
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![exe](https://img-home.csdnimg.cn/images/20210720083343.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)