欢迎光临散文网 会员登陆 & 注册

用python画的蜡笔小新

2019-07-25 10:40 作者:这个骚年很可耐  | 我要投稿

代码内容如下:

这里要导入一个turtle库,关于此库的函数用法在本站的北京理工大学嵩天老师python课程的第二章里有所介绍,在此不一一赘述。

import turtle as t

t.setup(650,300,200,200)

t.pu()

t.fd(250)

t.seth(90)

t.pd()

t.pensize(10)

t.pencolor('black')

#脸部轮廓

t.begin_fill()

t.color('moccasin')

t.circle(200,180)

t.seth(-180)

t.circle(100,180)

t.fd(50)

t.circle(500,40)


#画耳朵

t.seth(-90)

t.circle(55,45)

t.seth(90)

t.seth(30)

t.fd(45)

t.seth(360)

t.circle(55,255)

t.end_fill()

#画嘴巴

t.pu()

t.goto(-120,-100)

t.pensize(1)

t.begin_fill()

t.color('red')

t.circle(35,360)

t.end_fill()

#画左眼

t.goto(-75,50)

t.begin_fill()

t.color('black')

t.pd()

t.circle(35,360)

t.end_fill()


#画左眼眼白

t.goto(-65,50)

t.begin_fill()

t.color('white')

t.circle(16.5,360)

t.end_fill()


#右眼

t.pu()

t.goto(45,50)

t.begin_fill()

t.color('black')

t.pd()

t.circle(35,360)

t.end_fill()


#画右眼眼白

t.goto(55,50)

t.begin_fill()

t.color('white')

t.circle(16.5,360)

t.end_fill()


#画眉毛

t.pu()

t.seth(90)

t.goto(5,70)

t.pensize(1)

t.pencolor('black')

t.pd()

t.circle(45,180)


t.pu()

t.seth(90)

t.goto(5,110)

t.pensize(15)

t.pencolor('black')

t.pd()

t.circle(45,180)


t.pu()

t.seth(90)

t.goto(125,70)

t.pensize(1)

t.pencolor('black')

t.pd()

t.circle(45,180)


t.pu()

t.seth(90)

t.goto(125,110)

t.pensize(15)

t.pencolor('black')

t.pd()

t.circle(45,180)


#画头发

t.pu()

t.goto(255,25)

t.seth(90)

t.pd()

t.pensize(10)

t.begin_fill()

t.color('black')

t.circle(200,120)

t.seth(-15)

t.fd(280)

t.seth(-90)

t.fd(100)

t.seth(360)

t.fd(25)

t.end_fill()

个人感觉还是有所欠缺,因此还希望大佬多多指正!

用python画的蜡笔小新的评论 (共 条)

分享到微博请遵守国家法律