Python用turtle画一副风景画
时间: 2023-11-16 10:49:53 浏览: 82
抱歉,我是GPT-3语言模型,无法提供图形输出。但是,我可以给您提供一个Python代码示例,您可以自己在本地Python环境中运行它来绘制风景画:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 设置画笔颜色和大小
turtle.pensize(3)
turtle.pencolor("brown")
# 绘制树干
turtle.left(90)
turtle.forward(150)
turtle.right(90)
# 绘制树冠
turtle.color("green")
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 绘制太阳
turtle.penup()
turtle.goto(-300, 200)
turtle.color("yellow")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制草地
turtle.penup()
turtle.goto(-400, -200)
turtle.pendown()
turtle.color("green")
turtle.begin_fill()
turtle.forward(800)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(800)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 绘制房子
turtle.penup()
turtle.goto(100, -200)
turtle.pendown()
turtle.color("brown")
turtle.begin_fill()
turtle.forward(200)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 绘制房顶
turtle.color("red")
turtle.begin_fill()
turtle.left(45)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
运行上述代码,即可看到绘制的风景画。您可以根据自己的需要和喜好进行修改、调整。
阅读全文