蜡笔小新Python海龟绘图
时间: 2023-12-14 10:32:46 浏览: 207
使用Python的turtle模块绘制蜡笔小新图案
5星 · 资源好评率100%
以下是使用Python的turtle模块绘制蜡笔小新图案的代码和效果展示:
```python
import turtle
# 设置画笔
pen = turtle.Turtle()
pen.speed(10)
pen.pensize(5)
# 绘制身体
pen.fillcolor('#E60012')
pen.begin_fill()
pen.circle(100)
pen.end_fill()
# 绘制脸部
pen.penup()
pen.goto(0, 120)
pen.pendown()
pen.fillcolor('#FEDFE1')
pen.begin_fill()
pen.circle(80)
pen.end_fill()
# 绘制眼睛
pen.penup()
pen.goto(-30, 170)
pen.pendown()
pen.fillcolor('#FFFFFF')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(30, 170)
pen.pendown()
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.fillcolor('#000000')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(-10, 180)
pen.pendown()
pen.fillcolor('#000000')
pen.begin_fill()
pen.circle(5)
pen.end_fill()
pen.penup()
pen.goto(40, 180)
pen.pendown()
pen.begin_fill()
pen.circle(5)
pen.end_fill()
# 绘制鼻子
pen.penup()
pen.goto(0, 140)
pen.pendown()
pen.fillcolor('#FF5B00')
pen.begin_fill()
pen.circle(15)
pen.end_fill()
# 绘制嘴巴
pen.penup()
pen.goto(-50, 100)
pen.pendown()
pen.right(45)
pen.circle(70, 90)
pen.penup()
pen.goto(-50, 100)
pen.pendown()
pen.left(90)
pen.circle(70, 90)
# 绘制手臂
pen.penup()
pen.goto(-100, 0)
pen.pendown()
pen.right(45)
pen.fillcolor('#E60012')
pen.begin_fill()
pen.circle(50, 180)
pen.right(90)
pen.forward(100)
pen.right(90)
pen.circle(-50, 180)
pen.right(90)
pen.forward(100)
pen.end_fill()
# 绘制腿
pen.penup()
pen.goto(0, -100)
pen.pendown()
pen.right(90)
pen.fillcolor('#E60012')
pen.begin_fill()
pen.forward(100)
pen.right(90)
pen.circle(-50, 180)
pen.right(90)
pen.forward(100)
pen.end_fill()
# 隐藏画笔
pen.hideturtle()
# 点击关闭窗口
turtle.done()
```
效果展示:
![蜡笔小新Python海龟绘图](https://i.imgur.com/5JZzvJL.png)
阅读全文