用python画一个草莓熊
时间: 2023-07-18 13:43:18 浏览: 220
python草莓熊代码
5星 · 资源好评率100%
下面是使用Python的turtle库绘制草莓熊的示例代码:
```python
import turtle
# 设置画笔
turtle.setup(800, 600)
turtle.pensize(3)
turtle.speed(10)
# 画头部
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画耳朵
turtle.penup()
turtle.goto(-60, 170)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 170)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-40, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画鼻子
turtle.penup()
turtle.goto(0, 80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-50, 60)
turtle.pendown()
turtle.right(45)
turtle.circle(70, 90)
turtle.penup()
turtle.goto(-50, 60)
turtle.pendown()
turtle.left(90)
turtle.circle(-70, 90)
# 画草莓
turtle.penup()
turtle.goto(-120, -100)
turtle.pendown()
turtle.begin_fill()
turtle.color("red")
turtle.circle(40)
turtle.end_fill()
turtle.begin_fill()
turtle.color("green")
turtle.goto(-80, -80)
turtle.circle(20)
turtle.goto(-120, -120)
turtle.circle(20)
turtle.end_fill()
# 画身体
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画手
turtle.penup()
turtle.goto(-100, -150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画脚
turtle.penup()
turtle.goto(-60, -250)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(60, -250)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
运行代码后,将会在窗口中显示出草莓熊的图案。您可以根据自己的需求进行修改和美化。
阅读全文