帮我写一个python代码画草莓熊
时间: 2023-08-28 19:13:04 浏览: 2642
好的,以下是一个简单的 Python 代码,可以用 Turtle 绘制一个草莓熊:
```python
import turtle
# 设置画笔
turtle.pensize(3)
turtle.pencolor("black")
turtle.speed(1)
# 绘制草莓
turtle.fillcolor("#FF4F4F")
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 绘制草莓叶子
turtle.fillcolor("#8BC34A")
turtle.begin_fill()
turtle.right(60)
turtle.forward(80)
turtle.right(120)
turtle.forward(80)
turtle.right(120)
turtle.forward(80)
turtle.right(150)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(60)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(60)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.end_fill()
# 绘制熊耳朵
turtle.penup()
turtle.goto(-30, 100)
turtle.pendown()
turtle.fillcolor("#8BC34A")
turtle.begin_fill()
turtle.left(150)
turtle.forward(50)
turtle.right(120)
turtle.forward(50)
turtle.right(120)
turtle.forward(50)
turtle.end_fill()
turtle.penup()
turtle.goto(30, 100)
turtle.pendown()
turtle.fillcolor("#8BC34A")
turtle.begin_fill()
turtle.left(150)
turtle.forward(50)
turtle.right(120)
turtle.forward(50)
turtle.right(120)
turtle.forward(50)
turtle.end_fill()
# 绘制熊眼睛
turtle.penup()
turtle.goto(-20, 40)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(20, 40)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-20, 60)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(20, 60)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘制结果
turtle.done()
```
运行上述代码,可以得到一个草莓熊的图像。
阅读全文