用python画一个哆啦A梦
时间: 2023-10-29 13:07:16 浏览: 84
用Python画哆啦A梦
好的,以下是用 Python 画哆啦A梦的代码:
```python
import turtle
# 设置画板大小和背景色
turtle.setup(800, 600)
turtle.bgcolor('white')
# 定义哆啦A梦的身体函数
def body(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.color('#00A1E5')
turtle.circle(50)
turtle.end_fill()
# 定义哆啦A梦的脸函数
def face(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FDB813')
turtle.circle(40)
turtle.end_fill()
# 定义哆啦A梦的眼睛函数
def eye(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.color('#ffffff')
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(x-10, y+25)
turtle.pendown()
turtle.begin_fill()
turtle.color('#000000')
turtle.circle(8)
turtle.end_fill()
# 定义哆啦A梦的鼻子函数
def nose(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FF2D2D')
turtle.circle(10)
turtle.end_fill()
# 定义哆啦A梦的嘴巴函数
def mouth(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.color('#FF2D2D')
turtle.right(20)
turtle.circle(50, 100)
turtle.right(180)
turtle.circle(-50, 100)
# 画出哆啦A梦的身体、脸、眼睛、鼻子和嘴巴
body(0, 0)
face(0, 50)
eye(-20, 80)
eye(20, 80)
nose(0, 60)
mouth(0, 30)
# 隐藏画笔
turtle.hideturtle()
# 点击关闭窗口
turtle.exitonclick()
```
希望能帮到你,有什么问题可以随时问我哦!
阅读全文