python --turtle库绘制小猪佩奇

先贴上运行结果:代码:import turtle# 鼻子def nose(x, y): # 提笔 turtle.penup() # 定位 turtle.goto(x, y) # 落笔,开始画 turtle.pendown()# 将乌龟的方向设置为to_angle 为数字(0-东、90-北、180-西、270-南) ...
摘要由CSDN通过智能技术生成

先贴上运行结果:

 

代码:

import turtle

# 鼻子
def nose(x, y):
    # 提笔
    turtle.penup()
    # 定位
    turtle.goto(x, y)
    # 落笔,开始画
    turtle.pendown()

# 将乌龟的方向设置为to_angle 为数字(0-东、90-北、180-西、270-南)
    turtle.setheading(-30)
    turtle.begin_fill()  # 准备开始填充图形 8| a=0.4
    a=0.4
    for i in range(120):
        if 0 <= i < 30 or 60 <= i < 90:
            a = a + 0.08
            turtle.left(3)  # 向左转3度
            turtle.forward(a)


        else:
            a = a -0.08
            turtle.left(3)
            turtle.forward(a)
    turtle.end_fill()  # 填充完成
    turtle.penup()

    turtle.setheading(90)
    turtle.forward(25)
    turtle.pendown()
    turtle.pencolor(255, 155, 192)#画笔颜色
    turtle.setheading(10)
    turtle.begin_fill()
    turtle.circle(5)
    turtle.color(160, 82, 45)#返回或设置pencolor和fillcolor
    turtle.end_fill()
    turtle.penup()
    turtle.setheading(0)
    turtle.forward(20)
    turtle.pendown()
    turtle.pencolor(255, 155, 192)
    turtle.setheading(10)
    turtle.begin_fill()
    turtle.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值