用python的turtle画一个QQ的企鹅头像

今天想画个图,看中了桌面上的QQ头像

代码如下:

import turtle


t = turtle.Turtle()
t.speed(0)
#脸
t.color('black')
t.begin_fill()
t.circle(60)
t.end_fill()
#左眼
t.goto(-18,60)
t.pd()
t.color('white')
t.begin_fill()
t.circle(15)
t.end_fill()
t.pu()
t.color('black')

t.goto(-18,75)
t.begin_fill()

t.dot(15)
t.end_fill()

#右眼
t.goto(18,60)
t.pd()
t.color('white')
t.begin_fill()
t.circle(15)
t.end_fill()
t.pu()
t.color('black')
for i in range(8):

    t.goto(16+i,75)
    t.begin_fill()

    t.dot(5)
    t.end_fill()





#嘴巴
#

t.color('yellow')

t.pu()
t.home()

t.goto(-30,40)


t.seth(-35)
t.pd()
t.begin_fill()
t.circle(60,70)
t.pu()
t.goto(35,45)
t.seth(150)


t.pd()
t.circle(60,70)
t.end_fill()

#肚子

t.pu()
t.goto(0,20)
t.seth(180)
t.pensize(10)
t.pd()
t.color('black','white')
t.begin_fill()
t.circle(65)
t.end_fill()
t.pensize(1)

#围巾
t.pu()
t.goto(-55,20)
t.pd()
t.color('red')
t.pensize(32)

t.seth(-20)
t.circle(160,42)
t.pu()
t.pensize(1)
t.goto(-30,0)
t.pd()
t.begin_fill()
t.goto(-5,0)
t.goto(-5,-35)
t.goto(-30,-35)
t.goto(-30,0)
t.end_fill()

#左手
t.goto(-72,20)
t.color('black')
t.begin_fill()

t.goto(-105,-50)
t.goto(-40,0)
t.goto(-72,20)
t.end_fill()
#右手
t.pu()
t.goto(76,20)
t.pd
t.color('black')
t.begin_fill()

t.goto(105,-50)
t.goto(40,0)
t.goto(76,20)
t.end_fill()

#左脚

t.goto(-50,-95)
t.color('yellow')
t.begin_fill()
t.goto(-90,-115)
t.goto(0,-115)
t.goto(-50,-95)
t.end_fill()
#右脚
t.goto(50,-95)
t.color('yellow')
t.begin_fill()
t.goto(90,-115)
t.goto(0,-115)
t.goto(50,-95)
t.end_fill()




t.hideturtle()
turtle.done()

实现效果如下

用python的turtle画一个QQ的企鹅头像_第1张图片

你可能感兴趣的:(算法入门,python,开发语言)