Remplace chaque segment par 4 segments, définis par 3 points cassant le segment unité.
von Koch: a=1/3 b=0.5-sqrt(3)*1J/6 c=2/3
from kandinsky import* # von Koch: a=1/3 b=0.5-0.866*1J/3 c=2/3 def ligne(u,v): n = round(abs(v-u)) for i in range(n): w=u+i*(v-u)/n set_pixel(round(w.real),round(w.imag), color(0,0,0)) def fractal4(u=10+150*1J,v=310+150*1J,n=5): if n<1: ligne(u,v) else: fractal4(u,u+a*(v-u),n-1) fractal4(u+a*(v-u),u+b*(v-u),n-1) fractal4(u+b*(v-u),u+c*(v-u),n-1) fractal4(u+c*(v-u),v,n-1) fractal4()