import turtle as t
t.screensize(canvwidth =None,canvheight=None,bg="#999")
t.setup(width=1.0,height=1.0,startx=-1,starty=-1)
#设置画笔的大小
t.pensize(2)
#设置画笔速度
t.speed(10)
t.penup()
t.goto(-500,100)
t.color("#0dd","#0f0")
t.begin_fill()
for i in range(41):
t.pendown()
t.fd(150)
t.seth(80+80*i-i)
t.end_fill()
#提笔
t.up()
#变量清零
del(i)
#
#五角星
#
t.goto(-600,-100)
t.color("red","yellow")
t.begin_fill()
i = 0
while i< 5:
i+=1
t.down()
t.forward(200)
t.setheading(-144*i)
t.end_fill()
t.up()
del(i)
#
#小蟒蛇
#
t.goto(0,300)
t.pencolor("#0df")
t.pensize(5)
t.down()
t.seth(-45)
i =0
while i < 33:
i += 1
t.circle(5,90)
t.circle(-5,100)
t.up()
del(i)
#
#彩色小蟒蛇
#
t.goto(0,0)
colors =['black','grey','darkgreen','gold','violet','purple','green','red']
def huitu(r,angle,length):
t.seth(-40)
for i in range(length):
print(i%8)
t.pencolor(colors[i%8])
t.circle(r,angle)
t.pencolor(colors[(i+1)%8])
t.circle(-r,angle)
t.circle(r,angle/2)
t.fd(40)
t.circle(16,180)
t.fd(40*2/3)
t.penup()
t.fd(-350)
t.down()
t.pensize(25)
huitu(35,80,10)
t.done()
python绘图turtle之五角星与小蟒蛇
最新推荐文章于 2023-09-19 17:22:40 发布