用python画草莓熊代码
时间: 2023-11-12 10:56:44 浏览: 851
以下是用Python Turtle库绘制草莓熊的代码:
```python
import turtle
# 绘制草莓熊身体
def draw_body():
turtle.penup()
turtle.goto(-100,0)
turtle.pendown()
turtle.circle(100)
turtle.fillcolor("#C04C4D")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制草莓熊耳朵
def draw_ear(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.setheading(60)
turtle.circle(-50, 240)
turtle.fillcolor("#F8A5A5")
turtle.begin_fill()
turtle.setheading(60)
turtle.circle(-50, 240)
turtle.end_fill()
# 绘制草莓熊眼睛
def draw_eye(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制草莓熊脸部
def draw_face():
turtle.penup()
turtle.goto(-70, 70)
turtle.pendown()
turtle.fillcolor("#F8A5A5")
turtle.begin_fill()
for i in range(2):
turtle.forward(140)
turtle.circle(-20, 90)
turtle.forward(140)
turtle.circle(-20, 90)
turtle.end_fill()
# 绘制草莓熊嘴巴
def draw_mouth():
turtle.penup()
turtle.goto(-30, 0)
turtle.pendown()
turtle.setheading(315)
turtle.circle(50, 120)
turtle.penup()
turtle.goto(-30, 0)
turtle.pendown()
turtle.setheading(135)
turtle.circle(-50, 120)
# 绘制草莓熊鼻子
def draw_nose():
turtle.penup()
turtle.goto(-10, -20)
turtle.pendown()
turtle.fillcolor("#F8A5A5")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制草莓熊手臂
def draw_arm(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.setheading(220)
turtle.forward(100)
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.setheading(320)
turtle.forward(100)
# 绘制草莓熊腿部
def draw_leg(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
for i in range(2):
turtle.forward(100)
turtle.circle(-20, 90)
turtle.end_fill()
# 绘制草莓熊的所有部分
def draw_strawberry_bear():
draw_body() # 绘制身体
draw_ear(-110, 120) # 绘制左耳
draw_ear(70, 120) # 绘制右耳
draw_eye(-50, 40) # 绘制左眼
draw_eye(50, 40) # 绘制右眼
draw_face() # 绘制脸部
draw_mouth() # 绘制嘴巴
draw_nose() # 绘制鼻子
draw_arm(-120, -20) # 绘制左手
draw_arm(80, -20) # 绘制右手
draw_leg(-60, -120) # 绘制左腿
draw_leg(10, -120) # 绘制右腿
turtle.setup(600, 600)
turtle.hideturtle()
turtle.speed(10)
draw_strawberry_bear()
turtle.done()
```
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)