用Python代码画一个美羊羊
时间: 2023-11-16 16:59:48 浏览: 97
很高兴为您画一个美羊羊!这里是用Python Turtle库的代码:
```python
import turtle
# 设置画布大小和画笔粗细
turtle.setup(800, 800)
turtle.pensize(5)
# 绘制羊身体
turtle.color("white", "#FEDD00")
turtle.begin_fill()
turtle.circle(150)
turtle.end_fill()
# 绘制羊脸部
turtle.penup()
turtle.goto(0, 50)
turtle.pendown()
turtle.color("white", "black")
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 绘制羊眼睛
turtle.penup()
turtle.goto(-40, 120)
turtle.pendown()
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(-40, 120)
turtle.pendown()
turtle.color("black", "black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 120)
turtle.pendown()
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 120)
turtle.pendown()
turtle.color("black", "black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制羊嘴巴
turtle.penup()
turtle.goto(0, 80)
turtle.pendown()
turtle.color("black", "white")
turtle.begin_fill()
turtle.circle(30, 180)
turtle.end_fill()
# 绘制羊四肢
turtle.penup()
turtle.goto(-100, -50)
turtle.pendown()
turtle.color("white", "#FEDD00")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -50)
turtle.pendown()
turtle.color("white", "#FEDD00")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(-130, -200)
turtle.pendown()
turtle.color("white", "#FEDD00")
turtle.begin_fill()
turtle.forward(260)
turtle.left(90)
turtle.circle(30, 180)
turtle.left(90)
turtle.forward(260)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 结束绘制
turtle.done()
```
运行代码,您将看到一个可爱的美羊羊画在屏幕上!