python画史迪仔源代码
时间: 2023-11-13 07:56:51 浏览: 242
好的,以下是使用Python绘制史迪仔的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#F0E68C")
# 绘制史迪仔的头部
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
turtle.circle(50)
turtle.end_fill()
# 绘制史迪仔的眼睛
turtle.penup()
turtle.goto(-70, 120)
turtle.pendown()
turtle.begin_fill()
turtle.color("#FFFFFF")
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-70, 130)
turtle.pendown()
turtle.begin_fill()
turtle.color("#000000")
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(-30, 120)
turtle.pendown()
turtle.begin_fill()
turtle.color("#FFFFFF")
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-30, 130)
turtle.pendown()
turtle.begin_fill()
turtle.color("#000000")
turtle.circle(5)
turtle.end_fill()
# 绘制史迪仔的嘴巴
turtle.penup()
turtle.goto(-70, 90)
turtle.pendown()
turtle.color("#FF69B4")
turtle.pensize(5)
turtle.right(90)
turtle.circle(20, 180)
# 绘制史迪仔的身体
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
for i in range(2):
turtle.forward(200)
turtle.circle(50, 180)
turtle.end_fill()
# 绘制史迪仔的手臂
turtle.penup()
turtle.goto(-150, 50)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
turtle.right(45)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(135)
turtle.forward(70)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 50)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
turtle.left(45)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(135)
turtle.forward(70)
turtle.end_fill()
# 绘制史迪仔的腿
turtle.penup()
turtle.goto(-50, -100)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
turtle.right(45)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(135)
turtle.forward(70)
turtle.end_fill()
turtle.penup()
turtle.goto(50, -100)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
turtle.left(45)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(135)
turtle.forward(70)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
阅读全文