Python学习笔记(一):turtle库的练习------用python画一只小猪佩奇

	在猪年就要有猪的样子。

在熟悉turtle库的同时,让我们一起用python画只精致的小猪猪吧!
话不多说,直接上码:

import turtle as t
peppa=t.Turtle()
peppa.pensize(5)
peppa.speed(10)
peppa.color("#fe91b6","#fec7df")
peppa.getscreen().bgcolor("green")    #窗体背景颜色


#head
peppa.pu()
peppa.goto(130,80)
peppa.pd()
peppa.left(110)
peppa.begin_fill()
a=0.08
for b in range(2):
    for i in range(120):
        if i<60:
            a+=0.07
        else:
            a-=0.07
        peppa.right(-1.5)
        peppa.forward(a)
peppa.end_fill()
peppa.pu()
peppa.goto(100,100)
peppa.pd()
peppa.setheading(40)
peppa.begin_fill()
a=0.5
for b in range(2):
    for i in range(60):
        if i<30:
            a+=0.05
        else:
            a-=0.05
        peppa.right(3)
        peppa.forward(a)
peppa.end_fill()
peppa.pu()
peppa.goto(127,79)
peppa.pd()
peppa.circle(3)
peppa.pu()
peppa.goto(112,73)
peppa.pd()
peppa.circle(3)


#face
peppa.begin_fill()
peppa.pu()
peppa.goto(-68,4)
peppa.setheading(-90)
peppa.pd()
peppa.circle(80,182)
peppa.end_fill()


#eyes
peppa.pu()
peppa.goto(80,80)
peppa.pd()
peppa.color("#fe91b6","white")
peppa.begin_fill()
peppa.circle(15)
peppa.end_fill()
peppa.pu()
peppa.goto(67,75)
peppa.pd()
peppa.color("black","black")
peppa.begin_fill()
peppa.circle(5)
peppa.end_fill()

peppa.pu()
peppa.color("#fe91b6","white")
peppa.goto(40,70)
peppa.pd()
peppa.begin_fill()
peppa.circle(15)
peppa.end_fill()
peppa.pu()
peppa.goto(27,65)
peppa.pd()
peppa.color("black","black")
peppa.begin_fill()
peppa.circle(5)
peppa.end_fill()

peppa.pu()
peppa.goto(10,5)
peppa.pd()
peppa.color("#fe91b6","#fe91b6")
peppa.begin_fill()
peppa.circle(30)
peppa.end_fill()


#mouth
peppa.pu()
peppa.goto(60,10)
peppa.pd()
peppa.pencolor("#e52164")
peppa.setheading(270)
a=0.5
for i in range(50):
    if i<25:
        a+=0.05
    else:
        a-=0.05
    peppa.right(3)
    peppa.forward(a)


#ears
peppa.pu()
peppa.goto(18,105)
peppa.pd()
peppa.color("#fe91b6","#fec7df")
peppa.setheading(60)
peppa.begin_fill()
a=0.3
for b in range(2):
    for i in range(60):
        if i<30:
            a+=0.05
        else:
            a-=0.05
        peppa.right(-3)
        peppa.forward(a)
peppa.end_fill()

peppa.pu()
peppa.goto(-25,87)
peppa.pd()

peppa.begin_fill()
a=0.3
for b in range(2):
    for i in range(60):
        if i<30:
            a+=0.05
        else:
            a-=0.05
        peppa.right(-3)
        peppa.forward(a)
peppa.end_fill()

t.done()

在最后也祝大家猪年快乐吖

你可能感兴趣的:(Python,notes)