コード例 #1
0
ファイル: solids.py プロジェクト: fogleman/Carolina
def create_shape(sides, length):
    p = create_points(sides, length)
    g = GCode()
    g += GCode.from_points(p, G0Z, -0.24)
    # g += GCode.from_points(p, G0Z, -0.4)
    # g += GCode.from_points(p, G0Z, -0.5)
    # g = g.rotate_and_scale_to_fit(6.5, 8)
    # g = g.rotate(180)
    g = g + g.translate(0, 4)
    g = g.origin()
    g = HEADER + g + FOOTER
    g.save('solids.nc')
    im = g.render(0, 0, 6.5, 8, 96)
    im.write_to_png('solids.png')
コード例 #2
0
ファイル: tile.py プロジェクト: fogleman/Carolina
def main():
    counties = load_polygons(COUNTY_SHAPEFILE)
    state = load_polygons(STATE_SHAPEFILE)
    for y in range(4):
        for x in range(14):
            tile = create_tile(x, y, 6, 8)
            county_shapes = intersection(counties, tile)
            state_shapes = intersection(state, tile, -0.25)
            if not county_shapes and not state_shapes:
                continue
            print x, y, len(county_shapes), len(state_shapes)
            g = GCode()
            for shape in county_shapes:
                g += GCode.from_geometry(shape, G0Z, G1Z_COUNTY)
            for shape in state_shapes:
                g += GCode.from_geometry(shape, G0Z, G1Z_STATE1)
            for shape in state_shapes:
                g += GCode.from_geometry(shape, G0Z, G1Z_STATE2)
            g = g.translate(-tile.bounds[0], -tile.bounds[1])
            g = HEADER + g + FOOTER
            g.save('tiles/%02d.%02d.nc' % (y, x))
            p = 0.1
            surface = g.render(0 - p, 0 - p, 6 + p, 8 + p, 96)
            surface.write_to_png('tiles/%02d.%02d.png' % (y, x))