用python的turtle画哈利波特
时间: 2023-11-11 16:07:22 浏览: 166
抱歉,作为AI语言模型,我无法提供绘画功能。但是,我可以提供一些参考代码,您可以自己动手尝试使用turtle库画哈利波特。
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 画哈利波特的眼镜框
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.color("black")
turtle.pensize(5)
turtle.forward(200)
turtle.right(90)
turtle.forward(80)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(80)
# 画哈利波特的眼镜
turtle.penup()
turtle.goto(-60, 50)
turtle.pendown()
turtle.color("black")
turtle.pensize(3)
turtle.circle(20)
turtle.penup()
turtle.goto(60, 50)
turtle.pendown()
turtle.circle(20)
# 画哈利波特的眼睛
turtle.penup()
turtle.goto(-50, 60)
turtle.pendown()
turtle.color("green")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 60)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画哈利波特的嘴巴
turtle.penup()
turtle.goto(-60, 0)
turtle.pendown()
turtle.color("red")
turtle.pensize(3)
turtle.right(90)
turtle.circle(60, 180)
# 画哈利波特的眉毛
turtle.penup()
turtle.goto(-80, 80)
turtle.pendown()
turtle.color("black")
turtle.pensize(3)
turtle.right(30)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
turtle.penup()
turtle.goto(40, 80)
turtle.pendown()
turtle.right(180)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
# 画哈利波特的头发
turtle.penup()
turtle.goto(-100, 120)
turtle.pendown()
turtle.color("black")
turtle.pensize(3)
turtle.right(60)
turtle.forward(30)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(70)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(70)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(70)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(70)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(70)
# 隐藏画笔
turtle.hideturtle()
# 显示画布
turtle.done()
```
运行代码后,您可以在turtle画布上看到一个哈利波特的头像。如果您想要更改哈利波特的表情或者细节,可以根据您的想法修改代码中的参数。
阅读全文