def circle_lines(r, count): im = Svg("circle_lies_" + str(r) + "_" + str(count) + ".svg") for i in range(count): x = -r + r * 2 / count * i y = sin(acos(x / r)) * r im.line(x, y, x, -y) im.line(y, x, -y, x) im.close()
def pentagram_absolute(l): im = Svg("penta_" + str(l) + ".svg") points = [] for i in range(5): points.append((cos(radians(72 * i)) * l, sin(radians(72 * i)) * l)) for i in range(5): im.line(points[i][0], points[i][1], points[(i + 1) % 5][0], points[(i + 1) % 5][1]) im.line(points[i][0], points[i][1], points[(i + 2) % 5][0], points[(i + 2) % 5][1]) im.close()
def test(): im = Svg("test.svg") sq = deepcopy(SQUARE_2) for line in sq: im.line(line[0][0], line[0][1], line[1][0], line[1][1]) trans = [shear(1.3), rotation(-10), scaling(0.9, 0.9), translation(50, 50)] for i in range(15): for i in range(4): p1, p2 = sq[i][0], sq[i][1] for tran in trans: p1, p2 = apply(p1, tran), apply(p2, tran) sq[i] = (p1, p2) for line in sq: im.line(line[0][0], line[0][1], line[1][0], line[1][1]) im.close()
def nested_polygons(poly=3, size=200, count=10): im = Svg("poly.svg") points = [] for i in range(count): r = size / count * (i + 1) points = [] for j in range(poly): points.append((cos(radians(360 / poly * j)) * r, sin(radians(360 / poly * j)) * r)) for i in range(poly): im.line(points[i][0], points[i][1], points[(i + 1) % poly][0], points[(i + 1) % poly][1]) im.close()
def mcrm(base, trans, iters): im = Svg("test.svg") for i in range(iters): new_base = [] for line in base: for tran in trans: p1, p2 = line for t in tran: p1, p2 = apply(p1, t), apply(p2, t) new_base.append((p1, p2)) base = new_base for line in base: im.line(line[0][0], line[0][1], line[1][0], line[1][1]) im.close()