turtle库_蟒蛇绘制

在这里插入图片描述

源代码:

"""

         日期:20/7/25
         功能:蟒蛇的绘制
"""
import turtle as tl
def draw_snake():
    #设置绘画框大小
    tl.setup(1000, 500)
    #初始化画笔坐标
    tl.pencolor('purple')
    tl.pensize(25)
    tl.penup()
    tl.forward(-300)
    tl.down()
    tl.seth(-45) #设置画笔的方向(括号内为角度)
    #用循环画四个弧即蛇身
    for i in range(4):
        tl.circle(50, 90)
        tl.circle(-50, 90)

    #画蛇头
    tl.seth(0)
    tl.forward(30)
    tl.circle(40, 180)
    tl.forward(30)

    return None

def draw_eye():
    tl.pensize(5)
    tl.color('black')
    # 画上侧眼
    tl.up()
    tl.goto(265.69,85.00)  
    tl.down()
    tl.circle(1)
    # 画下侧眼
    tl.up()
    tl.goto(265.69, 75.00) 
    tl.down()
    tl.circle(1)
    return None

def draw_tongue():
    #移动画笔
    tl.up()
    tl.goto(250.69, 80.00) 
    tl.down()
    #画舌头
    tl.color('red')
    tl.forward(20)
    # 隐藏画笔
    tl.hideturtle()  
    return None

def main():

    #画蛇身

    draw_snake()

    #画眼
    draw_eye()
    #画舌头
    draw_tongue()
    #使绘画框不自动消失
    tl.exitonclick()

if __name__ == '__main__':
    main()
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值