python画草莓熊
时间: 2023-06-29 20:13:46 浏览: 39
以下是使用 Python 的 turtle 模块绘制草莓熊的示例代码:
```python
import turtle
# 设置画笔颜色和大小
turtle.pensize(5)
turtle.pencolor('black')
# 画熊的头部
turtle.fillcolor('#B97C5D')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画熊的耳朵
turtle.fillcolor('#B97C5D')
turtle.begin_fill()
turtle.right(90)
turtle.circle(40, 180)
turtle.right(180)
turtle.circle(80, 180)
turtle.right(180)
turtle.circle(40, 180)
turtle.right(90)
turtle.end_fill()
# 画熊的眼睛
turtle.penup()
turtle.goto(-30, 80)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-25, 90)
turtle.pendown()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
turtle.penup()
turtle.goto(30, 80)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(25, 90)
turtle.pendown()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
# 画熊的嘴巴
turtle.penup()
turtle.goto(-40, 45)
turtle.pendown()
turtle.right(30)
turtle.circle(40, 60)
# 画草莓
turtle.penup()
turtle.goto(-70, -20)
turtle.pendown()
turtle.fillcolor('red')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 0)
turtle.pendown()
turtle.fillcolor('green')
turtle.begin_fill()
turtle.right(60)
turtle.forward(30)
turtle.right(120)
turtle.forward(30)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示窗口
turtle.done()
```
上述代码使用 turtle 绘制了一个草莓熊的头部、耳朵、眼睛、嘴巴和草莓。你可以根据自己的需要进行调整,比如改变颜色、大小和位置等等。