from polycalc import * screen_w, screen_h, clear_screen_init, set_buffer, show_exit = get_infos(("w","h","cli","sb","she")) get_infos = None try: import turtle turtle.hideturtle() turtle.speed(0) turtle.pensize(1) except ImportError: from ce_turtl import turtle turtle.speed(1) turtle.pensize(0) from math import sqrt def sierp(n, l): a, r = 60, 1 if n <= 0: for i in range (3): turtle.fd(l) turtle.left(a * 2) else: l /= 2 n -= 1 sierp(n, l) turtle.fd(l) sierp(n, l) turtle.bk(l) turtle.left(a) turtle.fd(l) turtle.right(a) r += 3 * sierp(n, l) turtle.left(a) turtle.bk(l) turtle.right(a) return r def rotsierp(n=6, n0=0, s=1, h=192, m=3): r = 0 l = (h - m - m*sqrt(3)) / sqrt(3) turtle.penup() turtle.left(90) turtle.fd(m / 2) turtle.right(90) for k in range(n0, n0 + n): turtle.pendown() t = sierp(k,l) turtle.penup() turtle.right(90) turtle.fd(m) turtle.left(30) r += t return r set_buffer() clear_screen_init() t = rotsierp(6, 0, 1, screen_h) show_exit()