给我用python绘制哆啦A梦
时间: 2023-11-21 11:04:22 浏览: 76
python画哆啦A梦
5星 · 资源好评率100%
好的,这里提供一种用turtle模块绘制哆啦A梦的方法,代码如下:
```python
import turtle
# 设置画笔大小和颜色
turtle.pensize(4)
turtle.pencolor("black")
# 画头部
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画耳朵
turtle.goto(-70, 160)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.goto(70, 160)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 画眼睛
turtle.goto(-50, 25)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.goto(50, 25)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.goto(-50, 45)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.goto(50, 45)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 画鼻子
turtle.goto(0, 0)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.goto(0, -20)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画嘴巴
turtle.goto(-50, -60)
turtle.pencolor("red")
turtle.right(90)
turtle.circle(50, 180)
# 画身体
turtle.pencolor("black")
turtle.goto(-100, -100)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.forward(200)
turtle.left(90)
turtle.circle(100, 180)
turtle.left(90)
turtle.forward(200)
turtle.end_fill()
# 画手
turtle.goto(-150, -100)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.right(45)
turtle.forward(70)
turtle.left(45)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(45)
turtle.forward(70)
turtle.end_fill()
turtle.goto(150, -100)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.left(45)
turtle.forward(70)
turtle.right(45)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(45)
turtle.forward(70)
turtle.end_fill()
# 画脚
turtle.goto(-80, -200)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.right(45)
turtle.forward(70)
turtle.left(45)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(45)
turtle.forward(70)
turtle.end_fill()
turtle.goto(80, -200)
turtle.fillcolor("#FBD8B1")
turtle.begin_fill()
turtle.left(45)
turtle.forward(70)
turtle.right(45)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(45)
turtle.forward(70)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 完成绘制
turtle.done()
```
运行上述代码,即可在turtle窗口中看到绘制好的哆啦A梦。效果如下图所示:
![哆啦A梦](https://cdn.jsdelivr.net/gh/Yousazoe/picBed/img/20210624161557.png)
阅读全文