Python绘图史迪仔
时间: 2023-12-25 08:28:52 浏览: 82
以下是Python绘图史迪仔的代码和效果图:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#F5DEB3")
# 设置画笔颜色和大小
turtle.pensize(4)
turtle.pencolor("#8B0000")
# 绘制头部
turtle.circle(100)
# 绘制眼睛
turtle.penup()
turtle.goto(-40, 120)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-40, 130)
turtle.pendown()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 120)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 130)
turtle.pendown()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制嘴巴
turtle.penup()
turtle.goto(-60, 80)
turtle.pendown()
turtle.right(60)
turtle.circle(80, 120)
# 绘制身体
turtle.penup()
turtle.goto(-150, -100)
turtle.pendown()
turtle.fillcolor("#FFDAB9")
turtle.begin_fill()
turtle.right(30)
turtle.forward(200)
turtle.right(120)
turtle.forward(200)
turtle.right(60)
turtle.forward(200)
turtle.right(120)
turtle.forward(200)
turtle.end_fill()
# 绘制四肢
turtle.penup()
turtle.goto(-100, -100)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.right(30)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -100)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.right(30)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.end_fill()
turtle.penup()
turtle.goto(-100, -200)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.right(30)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -200)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.right(30)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
效果图如下:
![史迪仔](https://img-blog.csdn.net/20180428154212994?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfYw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/q/75/format/webp)
阅读全文