03- pig Page

Import Turtle T AS 

t.pensize ( . 4) # Set brush width 
# t.hideturtle () # hidden brush 
t.colormode (255) # Color Mode is set rgb mode 
t.speed (10) # Set brush speed 
t.home ( ) # initialize brush position (origin), direction (east) 

DEF draw_nose (): 
    t.color (( 255, 155, 192), " Pink " ) 
    t.penup () 
    T. Goto ( -100,100 ) 
    t.pendown ( ) 
    t.seth ( -30 ) 
    t.begin_fill () 

    # nose contour 
    A = 0.4 for I in Range (120
    ):
        if 0<=i<30 or 60<=i<90:
            a+=0.08
            t.left(3)
            t.fd(a)
        else:
            a-=0.08
            t.left(3)
            t.fd(a)
    t.end_fill()

    #鼻孔
    t.penup()
    t.goto(-95,125)
    t.pendown()
    t.begin_fill()
    t.fillcolor(160,82,45)
    t.circle(5)
    t.end_fill()

    #第二个鼻孔
    t.penup()
    t.goto(-70,125)
    t.pendown()
    t.seth(10)
    t.begin_fill()
    t.fillcolor(160,82,45)
    t.circle(5)
    t.end_fill()


#头部
def draw_head():
    t.color((255, 155, 192), "pink")
    t.penup()
    t.goto(-70,166)
    t.seth(180)
    t.pendown()

    t.begin_fill()
    t.circle(300,-30)
    t.circle(100,-60)
    t.circle(80,-100)
    t.circle(150,-20)
    t.circle(60,-95)
    t.seth(161)
    t.circle(-300,15)

    t.penup()
    t.goto(-100,100)
    t.seth(-30)
    t.pendown()

    a=0.4
    for i in range(60):
        if 0<=i<30:
            a+=0.08
            t.left(3)
            t.fd(a)
        else:
            a-=0.08
            t.left (3 )) 
            T.fd (A) 

    t.end_fill () 


# ear 
DEF draw_ear (): 
    t.color (( 255, 155, 192), " Pink " ) 

    # first ear 
    t.penup () 
    T. Goto ( 6.5 , 157 ) 
    t.seth ( 100 ) 
    t.pendown () 

    t.begin_fill () 
    t.circle ( -50,50 ) 
    t.circle ( -10,120 ) 
    t.circle ( -50,54 ) 
    t.end_fill () 

    # second ear 
    t.penup () 
    T. Goto ( 59,137.5 
    t.seth ( 100)
    t.pendown()

    t.begin_fill()
    t.circle(-50,50)
    t.circle(-10,120)
    t.circle(-50,57)
    t.end_fill()


def draw_eye():
    #第一只眼睛
    t.color((255, 155, 192), "white")

    t.penup()
    t.goto(-14.5,109)
    t.seth(0)
    t.pendown()

    t.begin_fill()
    t.circle(15)
    t.end_fill()

    t.penup()
    t.goto(-17.5,121)
    t.seth(0)
    t.pendown()

    t.color("black")
    t.circle(3)

    #第二只眼睛
    t.color((255, 155, 192), "white")

    t.penup()
    t.goto(22.5,96)
    t.seth(0)
    t.pendown()

    t.begin_fill()
    t.circle(15)
    t.end_fill()

    t.penup()
    t.goto(19.5,108)
    t.seth(0)
    t.pendown()

    t.color("black")
    t.circle(3)

def draw_gill():
    t.color(255,155,192)
    t.penup()
    t.goto(84.5,13)
    t.seth(0)
    t.pendown()

    t.begin_fill()
    t.circle(30)
    t.end_fill()

def draw_mouth():
    t.color(255,60,20)
    t.penup()
    t.goto(-15.6,28)
    t.seth(-80)
    t.pendown()

    t.circle(30,40)
    t.circle(40,80)

def draw_body():
    t.color("red",(255,100,70))

    t.penup()
    t.goto(-32,-9.5)
    t.seth(-130)
    t.pendown()

    t.begin_fill()
    t.circle(100,10)
    t.circle(300,30)

    t.seth(0)
    t.fd(230)
    t.seth(90)

    t.circle(300,30)
    t.circle(100,3)

    t.seth(-135)
    t.circle(-80,63)
    t.circle(-150,24)

    t.end_fill()

def draw_hand():
    t.color(255,155,192)
#左手
    t.penup()
    t.goto(-57.5,-48)
    t.seth(-160)
    t.pendown()

    t.circle(300,15)

    t.penup()
    t.goto(-127,-69)
    t.seth(-10)
    t.pendown()

    t.circle(-20,90)

#右手
    t.penup()
    t.goto(126.5,-62)
    t.seth(-20)
    t.pendown()

    t.circle(300,15)

    t.penup()
    t.goto(193,-68.5)
    t.seth(-120)
    t.pendown()

    t.circle(20,90)

def draw_foot():
    #左脚
    t.pensize(10)
    t.pencolor(240, 128, 128)

    t.penup()
    t.goto(-0.5,-176.5)
    t.seth(-90)
    t.pendown()

    t.fd(40)

    t.seth(-180)
    t.pencolor("black")
    t.pensize(15)
    t.fd(20)

#右脚
    t.pensize(10)
    t.pencolor(240, 128, 128)

    t.penup()
    t.goto(69.5,-176.5)
    t.seth(-90)
    t.pendown()

    t.fd(40)

    t.seth(-180)
    t.pencolor("black")
    t.pensize(15)
    t.fd(20)


def main():
    draw_nose()
    draw_head()
    draw_ear()
    draw_eye()
    draw_gill()
    draw_mouth()
    draw_body()
    draw_hand()
    draw_foot()

if __name__=="__main__":
    main()
    t.done()

 

Guess you like

Origin www.cnblogs.com/zhanghua-322/p/11444028.html
pig
pig