用pythonturtle只用圆画熊猫头
时间: 2023-11-19 09:59:48 浏览: 152
好的,以下是使用PythonTurtle库绘制熊猫头的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(400, 400)
turtle.bgcolor("black")
# 设置画笔属性
turtle.pensize(3)
turtle.pencolor("white")
turtle.fillcolor("white")
turtle.speed(10)
# 画圆形
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画左耳
turtle.up()
turtle.goto(-50, 150)
turtle.down()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画右耳
turtle.up()
turtle.goto(50, 150)
turtle.down()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画左眼
turtle.up()
turtle.goto(-40, 60)
turtle.down()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画右眼
turtle.up()
turtle.goto(40, 60)
turtle.down()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画左眼珠
turtle.up()
turtle.goto(-35, 75)
turtle.down()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
turtle.fillcolor("white")
# 画右眼珠
turtle.up()
turtle.goto(45, 75)
turtle.down()
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
# 画鼻子
turtle.up()
turtle.goto(0, 20)
turtle.down()
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 画嘴巴
turtle.up()
turtle.goto(-30, 0)
turtle.down()
turtle.pensize(5)
turtle.right(90)
turtle.circle(30, 180)
turtle.done()
```
运行上述代码,即可在PythonTurtle的画布上看到一个熊猫头的轮廓。
阅读全文