Beispiel #1
0
def create_drawing(rule, h):
    rows = compute_rows(rule, h)
    rows = pad(rows)
    rows = crop_diagonal(rows)
    # rows = crop(rows)
    rows = pad(rows)
    pairs, points = form_pairs(rows)
    paths = [trim_pair(x, 0.25) for x in pairs]
    for x, y in points:
        paths.append(xy.circle(x, y, 0.25))
    drawing = xy.Drawing(paths)
    drawing = drawing.scale(1, -1).rotate(45)
    drawing = drawing.scale_to_fit(315, 380)
    return drawing
Beispiel #2
0
def create_drawing(rule, h):
    rows = compute_rows(rule, h)
    rows = pad(rows)
    rows = crop_diagonal(rows)
    # rows = crop(rows)
    rows = pad(rows)
    pairs, points = form_pairs(rows)
    paths = [trim_pair(x, 0.25) for x in pairs]
    for x, y in points:
        paths.append(xy.circle(x, y, 0.25))
    drawing = xy.Drawing(paths)
    drawing = drawing.scale(1, -1).rotate(45)
    drawing = drawing.scale_to_fit(315, 380)
    return drawing
Beispiel #3
0
def main():
    im = Image.open(sys.argv[1])

    paths = []

    # for x, y in get_points(im):
    #     paths.extend(create_paths(x, -y))

    # maze
    paths = []
    paths.extend(find_lines(im))
    for x, y in find_curve1(im):
        paths.append(xy.arc(x + 2, -y - 2, 2, 90, 180))
    for x, y in find_curve2(im):
        paths.append(xy.arc(x + 2, -y - 1, 2, 180, 270))
    for x, y in find_curve3(im):
        paths.append(xy.arc(x + 1, -y - 2, 2, 0, 90))
    for x, y in find_curve4(im):
        paths.append(xy.arc(x + 1, -y - 1, 2, 270, 360))
    for x, y in find_big_curve1(im):
        paths.append(xy.arc(x + 4, -y - 4, 4, 90, 180))
    for x, y in find_big_curve2(im):
        paths.append(xy.arc(x + 4, -y - 0, 4, 180, 270))
    for x, y in find_big_curve3(im):
        paths.append(xy.arc(x + 0, -y - 4, 4, 0, 90))
    for x, y in find_big_curve4(im):
        paths.append(xy.arc(x + 0, -y - 0, 4, 270, 360))
    for x, y in find_small_curve1(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 90, 180))
    for x, y in find_small_curve2(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 180, 270))
    for x, y in find_small_curve3(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 0, 90))
    for x, y in find_small_curve4(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 270, 360))
    for x, y in find_bar(im):
        paths.append([(x + 1, -y - 1), (x + 18, -y - 1)])
        paths.append([(x + 1, -y - 2), (x + 18, -y - 2)])
        paths.append([(x + 1, -y - 0), (x + 1, -y - 3)])
        paths.append([(x + 18, -y - 0), (x + 18, -y - 3)])
    maze_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    # ghosts
    paths = []
    for x, y in find_ghosts(im):
        paths.append(xy.arc(x + 6.5, -y + 4.5, 6.5, 0, 180))
        paths.append([(x, -y + 4.5), (x, -y - 2)])
        paths.append([(x + 13, -y + 4.5), (x + 13, -y - 2)])
        paths.append([(x, -y - 2), (x + 2, -y)])
        paths.append([(x + 4, -y - 2), (x + 2, -y)])
        paths.append([(x + 4, -y - 2), (x + 6.5, -y)])
        paths.append([(x + 13, -y - 2), (x + 13 - 2, -y)])
        paths.append([(x + 13 - 4, -y - 2), (x + 13 - 2, -y)])
        paths.append([(x + 13 - 4, -y - 2), (x + 13 - 6.5, -y)])
    ghost_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    # pacman
    paths = []
    x, y = 113, -189
    paths.append(xy.arc(x, y, 6.5, 225, 135 + 360))
    x1 = x + 6.5 * math.cos(math.radians(135))
    y1 = y + 6.5 * math.sin(math.radians(135))
    x2 = x + 6.5 * math.cos(math.radians(225))
    y2 = y + 6.5 * math.sin(math.radians(225))
    paths.append([(x1, y1), (x + 2, y)])
    paths.append([(x2, y2), (x + 2, y)])
    pacman_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    # dots
    paths = []
    for x, y in find_dots(im):
        paths.append(xy.circle(x + 1.5, -y - 1.5, 1))
    for x, y in find_big_dots(im):
        paths.append(xy.circle(x + 3.5, -y - 4.5, 4))
    dot_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    paths = maze_paths + ghost_paths + pacman_paths + dot_paths
    drawing = xy.Drawing(paths).scale_to_fit(315, 380)
    drawing.render().write_to_png('pac.png')
    xy.draw(drawing)
Beispiel #4
0
def main():
    im = Image.open(sys.argv[1])

    paths = []

    # for x, y in get_points(im):
    #     paths.extend(create_paths(x, -y))

    # maze
    paths = []
    paths.extend(find_lines(im))
    for x, y in find_curve1(im):
        paths.append(xy.arc(x + 2, -y - 2, 2, 90, 180))
    for x, y in find_curve2(im):
        paths.append(xy.arc(x + 2, -y - 1, 2, 180, 270))
    for x, y in find_curve3(im):
        paths.append(xy.arc(x + 1, -y - 2, 2, 0, 90))
    for x, y in find_curve4(im):
        paths.append(xy.arc(x + 1, -y - 1, 2, 270, 360))
    for x, y in find_big_curve1(im):
        paths.append(xy.arc(x + 4, -y - 4, 4, 90, 180))
    for x, y in find_big_curve2(im):
        paths.append(xy.arc(x + 4, -y - 0, 4, 180, 270))
    for x, y in find_big_curve3(im):
        paths.append(xy.arc(x + 0, -y - 4, 4, 0, 90))
    for x, y in find_big_curve4(im):
        paths.append(xy.arc(x + 0, -y - 0, 4, 270, 360))
    for x, y in find_small_curve1(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 90, 180))
    for x, y in find_small_curve2(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 180, 270))
    for x, y in find_small_curve3(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 0, 90))
    for x, y in find_small_curve4(im):
        paths.append(xy.arc(x + 2, -y - 2, 1, 270, 360))
    for x, y in find_bar(im):
        paths.append([(x + 1, -y - 1), (x + 18, -y - 1)])
        paths.append([(x + 1, -y - 2), (x + 18, -y - 2)])
        paths.append([(x + 1, -y - 0), (x + 1, -y - 3)])
        paths.append([(x + 18, -y - 0), (x + 18, -y - 3)])
    maze_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    # ghosts
    paths = []
    for x, y in find_ghosts(im):
        paths.append(xy.arc(x + 6.5, -y + 4.5, 6.5, 0, 180))
        paths.append([(x, -y + 4.5), (x, -y - 2)])
        paths.append([(x + 13, -y + 4.5), (x + 13, -y - 2)])
        paths.append([(x, -y - 2), (x + 2, -y)])
        paths.append([(x + 4, -y - 2), (x + 2, -y)])
        paths.append([(x + 4, -y - 2), (x + 6.5, -y)])
        paths.append([(x + 13, -y - 2), (x + 13 - 2, -y)])
        paths.append([(x + 13 - 4, -y - 2), (x + 13 - 2, -y)])
        paths.append([(x + 13 - 4, -y - 2), (x + 13 - 6.5, -y)])
    ghost_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    # pacman
    paths = []
    x, y = 113, -189
    paths.append(xy.arc(x, y, 6.5, 225, 135 + 360))
    x1 = x + 6.5 * math.cos(math.radians(135))
    y1 = y + 6.5 * math.sin(math.radians(135))
    x2 = x + 6.5 * math.cos(math.radians(225))
    y2 = y + 6.5 * math.sin(math.radians(225))
    paths.append([(x1, y1), (x + 2, y)])
    paths.append([(x2, y2), (x + 2, y)])
    pacman_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    # dots
    paths = []
    for x, y in find_dots(im):
        paths.append(xy.circle(x + 1.5, -y - 1.5, 1))
    for x, y in find_big_dots(im):
        paths.append(xy.circle(x + 3.5, -y - 4.5, 4))
    dot_paths = xy.join_paths(xy.sort_paths_greedy(paths))

    paths = maze_paths + ghost_paths + pacman_paths + dot_paths
    drawing = xy.Drawing(paths).scale_to_fit(315, 380)
    drawing.render().write_to_png('pac.png')
    xy.draw(drawing)
Beispiel #5
0
    for x in values:
        p = (x - lo) / (hi - lo)
        x = new_lo + p * (new_hi - new_lo)
        result.append(x)
    return result

random.seed(13)

N = 400

noises = [random.random() * 2 - 1 for _ in range(N)]
for _ in range(3):
    noises = low_pass(noises, 0.2)
noises = normalize(noises, -1, 1)

paths = []
x = 0
y = 0
m = 0.5
for i, n in enumerate(noises):
    r = i + 1 #N - i
    paths.append(xy.circle(x, y, r, 120))
    a = n * math.pi
    x += math.cos(a) * m
    y += math.sin(a) * m

drawing = xy.Drawing(paths)
s = 315 / 2.0
drawing = drawing.crop(-s, -s, s, s)
drawing.render().write_to_png('contain.png')
Beispiel #6
0
        p = (x - lo) / (hi - lo)
        x = new_lo + p * (new_hi - new_lo)
        result.append(x)
    return result


random.seed(13)

N = 400

noises = [random.random() * 2 - 1 for _ in range(N)]
for _ in range(3):
    noises = low_pass(noises, 0.2)
noises = normalize(noises, -1, 1)

paths = []
x = 0
y = 0
m = 0.5
for i, n in enumerate(noises):
    r = i + 1  #N - i
    paths.append(xy.circle(x, y, r, 120))
    a = n * math.pi
    x += math.cos(a) * m
    y += math.sin(a) * m

drawing = xy.Drawing(paths)
s = 315 / 2.0
drawing = drawing.crop(-s, -s, s, s)
drawing.render().write_to_png('contain.png')