用python的海龟画一个钢铁侠
时间: 2023-04-07 20:00:30 浏览: 277
我可以回答这个问题。以下是用Python的海龟库画一个钢铁侠的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("black")
# 画头盔
turtle.color("red")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-50, 150)
turtle.pendown()
turtle.color("white")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-70, 50)
turtle.pendown()
turtle.color("red")
turtle.pensize(10)
turtle.right(45)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
# 画身体
turtle.penup()
turtle.goto(-150, -100)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(300)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 画手臂
turtle.penup()
turtle.goto(-150, 0)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.end_fill()
turtle.penup()
turtle.goto(150, 0)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.end_fill()
# 画腿
turtle.penup()
turtle.goto(-100, -200)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.end_fill()
turtle.penup()
turtle.goto(50, -200)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
阅读全文