五星红旗python代码turtle
时间: 2023-11-08 08:05:18 浏览: 97
使用Python的turtle模块画国旗
五星红旗Python代码turtle:
```python
import turtle
# 设置画布大小
turtle.setup(width=800, height=600)
# 蓝色矩形
turtle.penup()
turtle.goto(-200, 150)
turtle.pendown()
turtle.color("blue")
turtle.begin_fill()
for i in range(2):
turtle.forward(400)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.end_fill()
# 大星星
turtle.penup()
turtle.goto(-120, 70)
turtle.setheading(305)
turtle.pendown()
turtle.color("yellow")
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
# 小星星1
turtle.penup()
turtle.goto(-80, 130)
turtle.setheading(0)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
# 小星星2
turtle.penup()
turtle.goto(-60, 90)
turtle.setheading(20)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
# 小星星3
turtle.penup()
turtle.goto(-60, 40)
turtle.setheading(20)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
# 小星星4
turtle.penup()
turtle.goto(-80, 0)
turtle.setheading(0)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
turtle.done()
```
阅读全文