绘制钢铁侠

import turtle

t = turtle.Pen()
t.pensize(5)
t.speed(0)
t.hideturtle()
def head():
    t.fillcolor("red")
    t.begin_fill()
    t.forward(50)
    t.left(45)
    t.forward(141)
    t.left(45)
    t.forward(180)
    t.circle(150,180)
    t.forward(180)
    t.left(45)
    t.forward(141)
    t.left(45)
    t.forward(50)
    t.end_fill()
def face():
    t.penup()
    t.goto(0,40)
    t.pendown()
    turtle.colormode(255)
    t.fillcolor(231,184,32)
    t.begin_fill()
    t.forward(30)
    t.right(45)
    t.fd(20)
    t.left(80)
    t.forward(60)
    t.left(45)
    t.forward(30)
    t.right(45)
    t.forward(40)
    for i in range(65):
        t.left(1)
        t.forward(0.3)
    t.forward(230)
    t.left(50)
    t.forward(50)
    t.left(80)
    t.forward(70)
    t.right(45)
    t.fd(40)
    t.right(80)
    t.fd(60)
    t.left(105)
    t.fd(60)
    for i in range(30):
        t.left(2)
        t.forward(1.5)
    t.fd(210)
    for i in range(60):
        t.left(1)
        t.forward(0.3)
    t.forward(40)
    t.right(60)
    t.fd(20)
    t.left(45)
    t.fd(50)
    t.end_fill()
    t.left(90)
    t.fd(35)
    t.right(45)
    t.fd(30)
def eye():
    t.setheading(35)
    t.fillcolor("white")
    t.pensize(3)
    t.penup()
    t.goto(-115,250)
    t.pendown()
    t.begin_fill()
    t.right(40)
    t.fd(75)
    t.right(60)
    t.fd(30)
    t.right(120)
    t.fd(50)
    t.right(45)
    t.fd(35)
    t.end_fill()
    t.right(135)
    t.fd(65)
    t.left(5)
    t.fd(60)
    t.left(10)
    t.fd(90)
    t.backward(80)
    t.begin_fill()
    t.right(90)
    t.fd(30)
    t.left(90)
    t.fd(50)
    t.left(45)
    t.fd(40)
    t.end_fill()
def mouth():
    t.penup()
    t.goto(-115,200)
    t.pendown()
    t.setheading(-45)
    for i in range(40):
        t.right(0.2)
        t.fd(1.5)

    t.penup()
    t.goto(120,200)
    t.pendown()
    t.setheading(-135)
    for i in range(40):
        t.left(0.2)
        t.fd(2)
    t.penup()
    t.goto(-75,65)
    t.pendown()
    t.setheading(45)
    t.fd(50)
    t.setheading(0)
    t.fd(80)
    t.setheading(-45)
    t.fd(65)
def main():
    head()
    face()
    eye()
    mouth()
    turtle.done()
if __name__ == "__main__":
    main()

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
好的,以下是一个利用turtle库绘制钢铁的示例代码: ```python import turtle # 设置布大小和背景颜色 turtle.setup(800, 800) turtle.bgcolor('black') # 钢铁的身体 turtle.penup() turtle.goto(-100, 0) turtle.pendown() turtle.color('#FF2400') turtle.begin_fill() turtle.setheading(45) turtle.circle(100, 180) turtle.setheading(-45) turtle.forward(200) turtle.setheading(-135) turtle.circle(100, 180) turtle.setheading(225) turtle.forward(200) turtle.end_fill() # 钢铁的头盔 turtle.penup() turtle.goto(-60, 150) turtle.pendown() turtle.color('#FFD700') turtle.begin_fill() turtle.circle(60) turtle.end_fill() turtle.penup() turtle.goto(-50, 180) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.circle(40) turtle.end_fill() turtle.penup() turtle.goto(10, 200) turtle.pendown() turtle.color('#FFD700') turtle.begin_fill() turtle.setheading(-90) turtle.circle(60, 180) turtle.setheading(90) turtle.circle(20, 180) turtle.end_fill() turtle.penup() turtle.goto(-60, 100) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.setheading(-30) turtle.forward(50) turtle.setheading(-120) turtle.forward(50) turtle.setheading(150) turtle.forward(50) turtle.setheading(60) turtle.forward(50) turtle.end_fill() # 钢铁的手臂 turtle.penup() turtle.goto(-200, 0) turtle.pendown() turtle.color('#FF2400') turtle.begin_fill() turtle.setheading(-45) turtle.circle(100, 180) turtle.setheading(45) turtle.forward(100) turtle.setheading(135) turtle.circle(100, 180) turtle.setheading(-135) turtle.forward(100) turtle.end_fill() # 钢铁的手掌 turtle.penup() turtle.goto(-300, 0) turtle.pendown() turtle.color('#FFD700') turtle.begin_fill() turtle.circle(50) turtle.end_fill() turtle.penup() turtle.goto(-320, 50) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.setheading(-30) turtle.forward(30) turtle.setheading(-120) turtle.forward(30) turtle.setheading(150) turtle.forward(30) turtle.setheading(60) turtle.forward(30) turtle.end_fill() # 钢铁的腿 turtle.penup() turtle.goto(-50, -200) turtle.pendown() turtle.color('#FF2400') turtle.begin_fill() turtle.setheading(-60) turtle.circle(100, 180) turtle.setheading(120) turtle.circle(100, 180) turtle.end_fill() # 钢铁的脚 turtle.penup() turtle.goto(0, -300) turtle.pendown() turtle.color('#FFD700') turtle.begin_fill() turtle.setheading(-90) turtle.circle(50, 180) turtle.setheading(90) turtle.circle(20, 180) turtle.end_fill() turtle.penup() turtle.goto(-70, -300) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.setheading(-30) turtle.forward(20) turtle.setheading(-120) turtle.forward(20) turtle.setheading(150) turtle.forward(20) turtle.setheading(60) turtle.forward(20) turtle.end_fill() # 完成绘制 turtle.done() ``` 您可以运行这段代码,查看绘制钢铁效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值