turtle画巴西国旗
时间: 2023-09-29 09:06:02 浏览: 145
好的,以下是使用Python中的turtle库画出巴西国旗的代码:
```python
import turtle
# 设置画布大小
turtle.setup(600, 400)
# 设置画笔颜色模式为RGB
turtle.colormode(255)
# 画蓝色背景矩形
turtle.penup()
turtle.goto(-300, 200)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor(0, 39, 118)
turtle.forward(600)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(600)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 画圆形和黄色菱形
turtle.penup()
turtle.goto(-100, 80)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor(255, 223, 0)
turtle.circle(80)
turtle.end_fill()
turtle.penup()
turtle.goto(-60, 0)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor(0, 39, 118)
turtle.right(45)
turtle.forward(113)
turtle.right(135)
turtle.forward(160)
turtle.right(135)
turtle.forward(113)
turtle.right(45)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
运行后,将会弹出一个窗口,显示出画出的巴西国旗。