用python画草莓熊的代码
时间: 2023-09-21 13:07:49 浏览: 714
python草莓熊代码
5星 · 资源好评率100%
草莓熊是一种可爱的卡通形象,您可以使用Python的图形库绘制它。以下是一个简单的示例代码:
```python
import turtle
# 设置画布和画笔
canvas = turtle.Screen()
pen = turtle.Turtle()
# 绘制草莓熊的身体
pen.penup()
pen.goto(0, -100)
pen.pendown()
pen.begin_fill()
pen.color('brown')
pen.circle(100)
pen.end_fill()
# 绘制草莓熊的耳朵
pen.penup()
pen.goto(-50, 50)
pen.pendown()
pen.begin_fill()
pen.color('brown')
pen.circle(50)
pen.end_fill()
pen.penup()
pen.goto(50, 50)
pen.pendown()
pen.begin_fill()
pen.color('brown')
pen.circle(50)
pen.end_fill()
# 绘制草莓熊的眼睛
pen.penup()
pen.goto(-30, 80)
pen.pendown()
pen.begin_fill()
pen.color('white')
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(30, 80)
pen.pendown()
pen.begin_fill()
pen.color('white')
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(-30, 95)
pen.pendown()
pen.begin_fill()
pen.color('black')
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(30, 95)
pen.pendown()
pen.begin_fill()
pen.color('black')
pen.circle(10)
pen.end_fill()
# 绘制草莓熊的嘴巴
pen.penup()
pen.goto(-50, 20)
pen.pendown()
pen.begin_fill()
pen.color('pink')
pen.circle(30, -180)
pen.end_fill()
# 绘制草莓熊的鼻子
pen.penup()
pen.goto(0, 50)
pen.pendown()
pen.begin_fill()
pen.color('pink')
pen.circle(20)
pen.end_fill()
# 隐藏画笔
pen.hideturtle()
# 显示画布
canvas.mainloop()
```
以上代码使用`turtle`库绘制草莓熊的身体、耳朵、眼睛、嘴巴和鼻子。您可以根据自己的需要进行修改和优化。
阅读全文