Tuesday, April 5, 2016

Some Mistake Often Provide Beautiful Result.

 :)

 Planned to coding tree branch of tree, fractal mode, using turtle module on python. Has some trouble on backward rule. It become flower, by definition, it's still tree, :)


import turtle

#buat pola di sini
#kura-kura menghadap ke atas
turtle.shape("turtle")
turtle.left(90)

s   = 37

lv  = 7

l   = 100
turtle.forward(l)

def mundur(l,level):
    l   = 4./3.*l
    turtle.backward(l)
    turtle.right(3*s)
    maju(l,level)

def maju(l,level):
    l   = 3./4.*l
    turtle.left(s)
    turtle.forward(l)
    level   +=1
    if level<=lv:
        maju(l,level)
    else:
        mundur(l,level)

maju(l,2)


#agar gambar tak langsung hilang
turtle.exitonclick()



 



.