用turtle画米奇卡通人物
时间: 2023-07-28 11:07:14 浏览: 101
好的,我可以为你提供一份Python代码,使用turtle库来画米奇卡通人物。请确保你已经安装了turtle库。
```python
import turtle
# 设置画笔大小和颜色
turtle.pensize(4)
turtle.pencolor('black')
# 画左耳朵
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.right(45)
turtle.circle(100, -90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(135)
turtle.circle(100, -90)
turtle.end_fill()
# 画右耳朵
turtle.penup()
turtle.goto(200,0)
turtle.pendown()
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.left(45)
turtle.circle(100, 90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(135)
turtle.circle(100, 90)
turtle.end_fill()
# 画脸
turtle.penup()
turtle.goto(100,0)
turtle.pendown()
turtle.fillcolor('#ffffff')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(50, 150)
turtle.pendown()
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(150, 150)
turtle.pendown()
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(50, 50)
turtle.pendown()
turtle.right(90)
turtle.circle(50, 180)
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行代码后,你就可以在窗口中看到一个米奇卡通人物的图像了。如果你想要更改颜色、大小或位置,可以根据自己的需要修改代码中的参数。
阅读全文