用PYTHON画一个巴特辛普森的图案
时间: 2023-10-31 11:06:41 浏览: 103
好的,以下是用Python绘制巴特辛普森的图案的代码:
```python
import turtle
# 设置窗口大小和背景色
turtle.setup(800, 600)
turtle.bgcolor("yellow")
# 绘制巴特辛普森的头部
turtle.penup()
turtle.goto(-200, 100)
turtle.pendown()
turtle.color("black", "yellow")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制巴特辛普森的眼睛
turtle.penup()
turtle.goto(-70, 180)
turtle.pendown()
turtle.color("black", "white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-70, 200)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(30, 180)
turtle.pendown()
turtle.color("black", "white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(30, 200)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制巴特辛普森的嘴巴
turtle.penup()
turtle.goto(-100, 50)
turtle.pendown()
turtle.color("black")
turtle.right(45)
turtle.circle(70, 90)
# 绘制巴特辛普森的身体
turtle.penup()
turtle.goto(-100, -100)
turtle.pendown()
turtle.color("black", "blue")
turtle.begin_fill()
turtle.forward(200)
turtle.right(90)
turtle.circle(50, 180)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 绘制巴特辛普森的手
turtle.penup()
turtle.goto(-100, -100)
turtle.pendown()
turtle.color("black", "yellow")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -100)
turtle.pendown()
turtle.color("black", "yellow")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制巴特辛普森的腿
turtle.penup()
turtle.goto(-50, -200)
turtle.pendown()
turtle.color("black", "blue")
turtle.begin_fill()
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.end_fill()
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.color("black", "blue")
turtle.begin_fill()
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.end_fill()
turtle.done()
```
希望你喜欢这个巴特辛普森的图案!
阅读全文