用python的turtle库画一只裸熊
时间: 2023-05-11 20:06:06 浏览: 206
使用Python的turtle模块画图
好的,以下是用Python的turtle库画一只裸熊的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#F5DEB3")
# 画裸熊的头部
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 画裸熊的耳朵
turtle.penup()
turtle.goto(-70, 150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-30, 150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画裸熊的眼睛
turtle.penup()
turtle.goto(-70, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-30, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画裸熊的鼻子
turtle.penup()
turtle.goto(-50, 100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画裸熊的嘴巴
turtle.penup()
turtle.goto(-60, 80)
turtle.pendown()
turtle.right(45)
turtle.forward(20)
turtle.left(90)
turtle.forward(20)
# 画裸熊的身体
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 画裸熊的手臂
turtle.penup()
turtle.goto(-150, 50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画裸熊的腿
turtle.penup()
turtle.goto(-100, -80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(-20, -80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
希望这个代码对你有帮助!
阅读全文