用Python画一个海绵宝宝
时间: 2023-05-30 21:04:21 浏览: 137
抱歉,作为AI语言模型,我无法提供绘画功能。但是,您可以尝试使用Python的turtle库来绘制海绵宝宝。以下是一个简单的示例代码:
```python
import turtle
# 设置小海绵的颜色
spongebob_color = "yellow"
# 创建画布和画笔
canvas = turtle.Screen()
pen = turtle.Turtle()
# 绘制小海绵的头部
pen.penup()
pen.goto(0, -150)
pen.pendown()
pen.fillcolor(spongebob_color)
pen.begin_fill()
pen.circle(150)
pen.end_fill()
# 绘制小海绵的眼睛
pen.penup()
pen.goto(-60, 50)
pen.pendown()
pen.fillcolor("white")
pen.begin_fill()
pen.circle(40)
pen.end_fill()
pen.penup()
pen.goto(-60, 70)
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(60, 50)
pen.pendown()
pen.fillcolor("white")
pen.begin_fill()
pen.circle(40)
pen.end_fill()
pen.penup()
pen.goto(60, 70)
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(20)
pen.end_fill()
# 绘制小海绵的嘴巴
pen.penup()
pen.goto(-100, -30)
pen.pendown()
pen.right(90)
pen.circle(100, 180)
# 绘制小海绵的裤子
pen.penup()
pen.goto(0, -250)
pen.pendown()
pen.fillcolor("brown")
pen.begin_fill()
pen.circle(150, 180)
pen.left(90)
pen.forward(150)
pen.left(90)
pen.circle(75, 180)
pen.end_fill()
# 绘制小海绵的腿
pen.penup()
pen.goto(-60, -250)
pen.pendown()
pen.fillcolor(spongebob_color)
pen.begin_fill()
pen.circle(60, 180)
pen.left(90)
pen.forward(60)
pen.left(90)
pen.circle(30, 180)
pen.end_fill()
pen.penup()
pen.goto(60, -250)
pen.pendown()
pen.fillcolor(spongebob_color)
pen.begin_fill()
pen.circle(60, 180)
pen.left(90)
pen.forward(60)
pen.left(90)
pen.circle(30, 180)
pen.end_fill()
# 完成绘制
pen.hideturtle()
canvas.exitonclick()
```
阅读全文