• 大小: 5.34KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2024-05-07
  • 语言: Python
  • 标签: python  py  小猪  

资源简介


代码片段和文件信息

from turtle import*

def nose(xy):#鼻子
    penup()#提起笔
    goto(xy)#定位
    pendown()#落笔,开始画
    setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
    begin_fill()#准备开始填充图形
    a=0.4
    for i in range(120):
        if 0<=i<30 or 60<=i<90:
            a=a+0.08
            left(3) #向左转3
            forward(a) #向前走a的步长
        else:
            a=a-0.08
            left(3
            forward(a)
    end_fill()#填充完成

    penup()
    setheading(90
    forward(25
    setheading(0
    forward(10
    pendown()
    pencolor(255155192)#画笔颜色
    setheading(10
    begin_fill()
    circle(5
    color(1608245)#返回或设置pencolor和fillcolor
    end_fill()

    penup()
    setheading(0
    forward(20
    pendown()
    pencolor(255155192
    setheading(10
    begin_fill()
    circle(5
    color(1608245
    end_fill()


def head(xy):#头
    color((255155192)“pink“)
    penup()
    goto(xy)
    setheading(0
    pendown()
    begin_fill()
    setheading(180
    circle(300-30
    circle(100-60
    circle(80-100
    circle(150-20
    circle(60-95
    setheading(161
    circle(-30015
    penup()
    goto(-100100
    pendown()
    setheading(-30
    a=0.4
    for i in range(60):
        if 0<=i<30 or 60<=i<90:
            a=a+0.08
            lt(3) #向左转3
            fd(a) #向前走a的步长
        else:
            a=a-0.08
            lt(3
            fd(a)
    end_fill()


def ears(xy): #耳朵
    color((255155192)“pink“)
    penup()
    goto(xy)
    pendown()
    begin_fill()
    setheading(100
    circle(-5050
    circle(-10120
    circle(-5054
    end_fill()

    penup()
    setheading(90
    forward(-12
    setheading(0
    forward(30
    pendown()
    begin_fill()
    setheading(100
    circle(-5050
    circle(-10120
    circle(-5056
    end_fill()


def eyes(xy):#眼睛
    color((255155192)“white“)
    penup()
    setheading(90
    forward(-20
    setheading(0
    forward(-95
    pendown()
    begin_fill()
    circle(15
    end_fill()

    color(“black“)
    penup()
    setheading(90
    forward(12
    setheading(0
    forward(-3
    pendown()
    begin_fill()
    circle(3
    end_fill()

    color((255155192)“white“)
    penup()
    seth(90
    forward(-25
    seth(0
    forward(40
    pendown()
    begin_fill()
    circle(15
    end_fill()

    color(“black“)
    penup()
    setheading(90
    forward(12
    setheading(0
    forward(

评论

共有 条评论