Esempio n. 1
0
def main():
    device = xy.Device()
    time.sleep(2)
    device.pen_up()
    time.sleep(1)
    device.home()
    model = Model()
    for x, y in polygon(5, 0.35):
        model.add(x, y, 1)
    model.add(0.5, 0.5, 0.1)
    total = 0
    while True:
        paths = []
        print 'generating paths'
        for _ in range(250):
            x = random.random()
            y = random.random()
            path = create_path(model, 315, 0, 35, x, y, -1, 100)
            path = xy.simplify(path)
            paths.append(path)
        print 'sorting paths'
        paths = xy.sort_paths(paths, 1000000)
        print 'drawing paths'
        for path in paths:
            total += 1
            print '%5d: %2d points @ (%.3f, %.3f)' % (
                total, len(path), path[0][0], path[0][1])
            device.draw(path)
Esempio n. 2
0
def main():
    device = xy.Device()
    time.sleep(2)
    device.pen_up()
    time.sleep(1)
    device.home()
    model = Model()
    for x, y in polygon(5, 0.35):
        model.add(x, y, 1)
    model.add(0.5, 0.5, 0.1)
    total = 0
    while True:
        paths = []
        print 'generating paths'
        for _ in range(250):
            x = random.random()
            y = random.random()
            path = create_path(model, 315, 0, 35, x, y, -1, 100)
            path = xy.simplify(path)
            paths.append(path)
        print 'sorting paths'
        paths = xy.sort_paths(paths, 1000000)
        print 'drawing paths'
        for path in paths:
            total += 1
            print '%5d: %2d points @ (%.3f, %.3f)' % (total, len(path),
                                                      path[0][0], path[0][1])
            device.draw(path)
Esempio n. 3
0
def main():
    device = xy.Device()
    time.sleep(2)
    device.pen_up()
    time.sleep(1)
    device.home()
    print 'parsing osm file'
    h = Handler()
    p = OSMParser(None, h.on_nodes, h.on_ways, h.on_relations, h.on_coords)
    p.parse('/Users/fogleman/Workspace/Manhattan/osm/manhattan.osm.pbf')
    print 'creating paths'
    paths = h.create_paths()
    print len(paths)
    print 'creating drawing'
    drawing = xy.Drawing(paths).scale(1, -1).scale_to_fit(315, 380)
    # print 'rendering drawing'
    # drawing.render().write_to_png('manhattan.png')
    paths = drawing.paths
    paths.sort(key=lambda path: path[0][1])
    n = 250
    for i in range(0, len(paths), n):
        print i
        for path in xy.sort_paths(paths[i:i+n], 500000):
            device.draw(xy.simplify(path, 0.1))
Esempio n. 4
0
def main():
    device = xy.Device()
    time.sleep(2)
    device.pen_up()
    time.sleep(1)
    device.home()
    print 'parsing osm file'
    h = Handler()
    p = OSMParser(None, h.on_nodes, h.on_ways, h.on_relations, h.on_coords)
    p.parse('/Users/fogleman/Workspace/Manhattan/osm/manhattan.osm.pbf')
    print 'creating paths'
    paths = h.create_paths()
    print len(paths)
    print 'creating drawing'
    drawing = xy.Drawing(paths).scale(1, -1).scale_to_fit(315, 380)
    # print 'rendering drawing'
    # drawing.render().write_to_png('manhattan.png')
    paths = drawing.paths
    paths.sort(key=lambda path: path[0][1])
    n = 250
    for i in range(0, len(paths), n):
        print i
        for path in xy.sort_paths(paths[i:i + n], 500000):
            device.draw(xy.simplify(path, 0.1))