1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 小猪佩奇python_「小猪佩奇头像」使用python中turtle绘制一个小猪佩奇的头像 - seo实验室...

小猪佩奇python_「小猪佩奇头像」使用python中turtle绘制一个小猪佩奇的头像 - seo实验室...

时间:2019-10-07 00:42:53

相关推荐

小猪佩奇python_「小猪佩奇头像」使用python中turtle绘制一个小猪佩奇的头像 - seo实验室...

小猪佩奇头像

之前一直被佩奇的预告片刷屏,就想着用Python中的turtle模块来自己绘制一个海报目前完成了一个头,代码如下;之后会更新整幅图from turtle import *

def eyes(x,y):#眼睛

penup()#提起笔

goto(x,y)#定位

setheading(90)

forward(25)

setheading(0)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)

forward(10)#向前走10的步长

pendown()#落笔,开始画

pencolor(255,155,192)#画笔颜色

setheading(15)

begin_fill()

circle(10)

setheading(80)

forward(9)

color(255,255,255)#返回或设置pencolor和fillcolor

begin_fill()

circle(6)

color(0,0,0)

end_fill()

def ears(x,y): #耳朵

penup()#提起笔

goto(x,y)#定位

color((255,155,192))

pendown()#落笔,开始画

setheading(-20)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)

begin_fill()#准备开始填充图形

a=0.4

for i in range (15,120):

if 15<=i<45 or 75<=i<110:

a=a+0.05

left(3)#向左转3度

forward(a)#向前走a的步长

else:

a=a-0.05

left(3)

forward(a)

end_fill()#填充完成

def nose(x,y): #鼻子

penup()#提起笔

goto(x,y)#定位

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(255,155,192)#画笔颜色

setheading(10)

begin_fill()

circle(5)

color(160,82,45)#返回或设置pencolor和fillcolor

end_fill()

penup()

setheading(0)

forward(20)

pendown()

pencolor(255,155,192)

setheading(10)

begin_fill()

circle(5)

color(160,82,45)

end_fill()

def head(x,y):#头

color((255,155,192),"pink")

penup()

goto(x,y)

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(-300,15)

penup()

goto(-100,100)

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 cheek(x,y):#腮

color((255,155,192))

penup()

goto(x,y)

pendown()

setheading(0)

begin_fill()

circle(30)

end_fill()

def mouth(x,y):#嘴

color(239,69,19)

penup()

goto(x,y)

pendown()

setheading(-80)

circle(30,40)

circle(40,80)

def setting():#参数设置

pensize(4)

hideturtle()#使乌龟无形(隐藏)

colormode(255)#将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内

color((255,155,192),"pink")

#setup(1024,740)

setup(780,500)

#speed(10) #设置绘图速度

Turtle().screen.delay(0)

def main():

setting()#画布、画笔设置

nose(-100,100)#鼻子

ears(42,140)#一只耳朵

ears(102,110)#另一只耳朵

head(-69,167)#头

eyes(0,85)#一只眼睛

eyes(45,70)#另一只眼睛

cheek(80,10)#腮

mouth(-20,30)#嘴

done()

main()

相关阅读

1. 什么是SOAP协议

SOAP 是一种简单的基于 XML 的协议,它底层通过 HTTP 来交换信息。SOAP的优点是可以传递结构化的数据。 客

后期文章陆续登在公众号

最近在学习数学建模,但是matlab用的不是很习惯,于是我尝试用python解决几道,别说还蛮顺手,以下知识点是老师

学python也快2个礼拜了,从开始看别人写的爬虫代码,然后试着抄着学习,感觉没太大进步,最大收获就是改了几处bug(可能有些地方不适用我的

Begals是可以和朋友一起玩的一个推理游戏。你的朋友想到一个随机的、没有重复的3位数字,你尝试去猜测它是什么。

每次猜测之后,朋友

昨天刷头条时得知赵丽颖当妈妈了。作为一名程序员突发奇想,不如用Python简单叙述一下冯绍峰和赵丽颖的爱情故事,于是有了本文。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。