使用python代码绘画一个小白兔
时间: 2024-05-25 19:13:22 浏览: 185
好的,我可以用Python的turtle模块来画一个小白兔。下面是代码:
```python
import turtle
# 创建画布和画笔
canvas = turtle.Screen()
canvas.bgcolor("white")
pen = turtle.Turtle()
pen.speed(0)
pen.color("black")
# 画兔耳朵
pen.fillcolor("#FCD5B5")
pen.begin_fill()
pen.setheading(60)
pen.circle(80, 60)
pen.setheading(120)
pen.circle(80, 120)
pen.end_fill()
# 画兔脸
pen.fillcolor("#FCD5B5")
pen.begin_fill()
pen.setheading(240)
pen.circle(80, 60)
pen.setheading(300)
pen.circle(80, 120)
pen.end_fill()
# 画眼睛
pen.penup()
pen.goto(-30, 40)
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(30, 40)
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 画嘴巴
pen.penup()
pen.goto(-20, 10)
pen.pendown()
pen.setheading(-45)
pen.circle(25, 90)
# 画身体
pen.penup()
pen.goto(-80, -80)
pen.pendown()
pen.fillcolor("#FCD5B5")
pen.begin_fill()
pen.setheading(60)
pen.circle(80, 60)
pen.setheading(120)
pen.circle(80, 120)
pen.setheading(-120)
pen.circle(80, 120)
pen.setheading(-60)
pen.circle(80, 60)
pen.end_fill()
# 画前腿
pen.penup()
pen.goto(-70, -80)
pen.pendown()
pen.fillcolor("#FCD5B5")
pen.begin_fill()
pen.setheading(-45)
pen.circle(40, 90)
pen.setheading(0)
pen.forward(30)
pen.end_fill()
# 画后腿
pen.penup()
pen.goto(10, -80)
pen.pendown()
pen.fillcolor("#FCD5B5")
pen.begin_fill()
pen.setheading(-135)
pen.circle(40, 90)
pen.setheading(180)
pen.forward(30)
pen.end_fill()
# 结束画笔
pen.hideturtle()
# 显示画布
turtle.done()
```
这个小白兔长这样:
![小白兔](https://cdn.jsdelivr.net/gh/kaito0925/blog-img-repo/img/rabbit.png)
阅读全文