Personal tools
You are here: o studio 110 2016-17 tmp Inf 11 doku doku .py script kochkurve_v2.py

Die einzige Konstante im Universum ist die Veränderung.

Heraklit von Ephesus

When you need a function, just declare it.

 

Ego ist eine Illusion.

Marco Asam

Life is like a camera -
focus on what's important
capture the good times,
develop from the negatives
and if things don't work out
take another shot.

Anonymous

 

 

 

 

 

 

 

 

 

kochkurve_v2.py

kochkurve_v2.py — Python Source, 0Kb

File contents

# -*- coding: cp1252 -*-
# kochkurve fraktale rekursion
from turtle import *
from time import *
#tracer(1,0)
speed(0)
ht()
farben=("yellow","green", "cyan","orange","red","brown","blue","black")

def kochkurve(t=1,s=200):
    "Kochkurve mit Rekusionstiefe t und L�e s"
    delay(0)
    if t==0:
        forward(s)
    else:
        kochkurve(t-1,s/3.)
        left(60)
        kochkurve(t-1,s/3.)
        right(120)
        kochkurve(t-1,s/3.)
        left(60)
        kochkurve(t-1,s/3.)

def schneeflocke(t=1,s=200):
    "Koch-Schneeflocke mit Rekursionstiefe t und L�e s"
    #clear()
    pencolor(farben[t])
    #tracer(t,10)
    kochkurve(t,s)
    right(120)
    kochkurve(t,s)
    right(120)
    kochkurve(t,s)
    right(120)
    sleep(5./(t+1))
    
if __name__=='__main__': 
    up()
    goto(-300,200)
    down()
    for i in range(0,9):
        schneeflocke(i,600)#,(i*50,i*50,i*50))
    exitonclick()
Document Actions