Пример #1
0
def render(f, lattice):
    theta = math.radians(45*f)
    square_radius = math.sqrt(2) * math.sin(math.pi/2 - theta) * lattice.u.magnitude()/2
    corner_deltas = [exp(radius=square_radius, angle=theta+lattice.u.angle()+math.radians(45+ 90*x)) for x in range(4)]

    img = Image.new("RGB", (window_size, window_size), "white")
    draw = ImageDraw.Draw(img)
    r = Rect(0,window_size, 0,window_size)
    for p in lattice.points_within(r.with_margin(lattice.u.magnitude())):
        corners = [p + delta for delta in corner_deltas]
        for a,b in iter_cycle(corners):
            draw.line(a.tuple()+b.tuple(), fill="black")
    return img
Пример #2
0
def rotated(vector, angle):
    return exp(vector.angle()+angle, vector.magnitude())