利用python的turtle画出甲贺忍蛙
时间: 2023-10-12 17:19:40 浏览: 247
好的,以下是利用 Python 的 turtle 模块画出甲贺忍蛙的代码:
```python
import turtle
# 设置窗口大小和背景颜色
turtle.setup(600, 600)
turtle.bgcolor("#3E3E3E")
# 设置画笔基本参数
turtle.pensize(3)
turtle.speed(10)
turtle.color("#FFFFFF")
# 画出甲贺忍蛙的头部
turtle.penup()
turtle.goto(0, 200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(-100, -180)
turtle.circle(100, -180)
turtle.end_fill()
# 画出甲贺忍蛙的眼睛
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 60)
turtle.pendown()
turtle.color("#3E3E3E")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 60)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画出甲贺忍蛙的身体
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.begin_fill()
turtle.circle(-150, -180)
turtle.circle(150, -180)
turtle.end_fill()
# 画出甲贺忍蛙的腹部
turtle.penup()
turtle.goto(0, -150)
turtle.pendown()
turtle.color("#FFFFFF")
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 画出甲贺忍蛙的腿
turtle.penup()
turtle.goto(-50, -200)
turtle.pendown()
turtle.color("#3E3E3E")
turtle.begin_fill()
turtle.circle(25, -180)
turtle.circle(-25, -180)
turtle.end_fill()
turtle.penup()
turtle.goto(50, -200)
turtle.pendown()
turtle.color("#3E3E3E")
turtle.begin_fill()
turtle.circle(-25, -180)
turtle.circle(25, -180)
turtle.end_fill()
# 画出甲贺忍蛙的手
turtle.penup()
turtle.goto(-150, -50)
turtle.pendown()
turtle.color("#3E3E3E")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(150, -50)
turtle.pendown()
turtle.color("#3E3E3E")
turtle.begin_fill()
turtle.circle(-25)
turtle.end_fill()
# 完成画图
turtle.done()
```
运行以上代码,即可看到甲贺忍蛙的画图结果。
阅读全文