import turtle
from random import randint
x = 20
y = 20
turtle.speed(100)
turtle.colormode(255)
def move(l, a):
turtle.right(a)
turtle.forward(l)
def hex():
turtle.pendown()
turtle.color( randint(0,255),randint(0,255),randint(0,255) )
turtle.begin_fill()
for i in range(6):
move(x,-60)
turtle.end_fill()
turtle.penup()
turtle.penup()
for z in range (y):
if z == 0:
hex()
move(x,-60)
move(x,-60)
move(x,-60)
move(0,180)
for i in range (6):
move(0,60)
for j in range (z+1):
hex()
move(x,-60)
move(x,60)
move(-x,0)
move(-x,60)
move(x,-120)
move(0,60)
turtle.exitonclick()
No comments:
Post a Comment