如何用Python快速画一只可爱的佩奇
代码搬运工:
Monster12138/Peppa-Pig: 使用python turtle库画一只小猪佩奇 https://github.com/Monster12138/Peppa-Pig
先上图哈
@可可爱爱@
代码搞起来:
# coding:utf-8
from turtle import*
def nose(x,y):#鼻子
pu()
goto(x,y)
pd()
seth(-30)
begin_fill()
a=0.4
for i in range(120):
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()
pu()
seth(90)
fd(25)
seth(0)
fd(10)
pd()
pencolor(255,155,192)
seth(10)
begin_fill()
circle(5)
color(160,82,45)
end_fill()
pu()
seth(0)
fd(20)
pd()
pencolor(255