Wednesday, April 6, 2016

Pohon Asimetris, :)

Modifikasi dari kode sebelumnya

import turtle
import numpy

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


lv  = 11
l   = 100
sl  = 47
sr  = 17

turtle.penup()
turtle.backward(l)
turtle.pendown()
turtle.forward(l)


def maju(l,level):
    l           = 3./4.*l
    #turtle.backward(l)
    turtle.left(sl)
    turtle.forward(l)
    level       += 1
    if level<lv:
        maju(l,level)
    
    turtle.backward(l)
    turtle.right(sl)
    turtle.right(sr)
    turtle.forward(l)
    if level    <lv:
        maju(l,level)
    turtle.backward(l)
    turtle.left(sr)
    level       -= 1

maju(l,2)


#agar gambar tak langsung hilang
turtle.exitonclick()



 



.