Esempio n. 1
0
def main():
    g0z = 0.2
    g1z = -0.01
    w = 32
    h = 6
    g = GCode()
    for i, (name, au, radius) in enumerate(PLANETS):
        p = (au + 0.25) / (PLANETS[-1][1] + 1)
        x = w * p
        t = GCode.from_file('text/%s.nc' % name)
        t = t.depth(0.2, -0.01)
        t = t.rotate(90).scale(0.2, 0.2)
        t = t.move(x, 0.75, 0.5, 0.5)
        _, ty1, _, ty2 = t.bounds
        g += t
        if i > 0:
            r = 1.2 * radius / 71492.68
            y1 = h / 2 - r
            y2 = h / 2 + r
            g += GCode(['G0 X%f Y%f' % (x, y1), 'G3 X%f Y%f I%f J%f' % (x, y2, 0, r), 'G3 X%f Y%f I%f J%f' % (x, y1, 0, -r)])
            g += GCode.from_points([(x, 0), (x, ty1 - 0.1)], g0z, g1z)
            g += GCode.from_points([(x, ty2 + 0.1), (x, y1-0.1)], g0z, g1z)
            g += GCode.from_points([(x, y2+0.1), (x, h)], g0z, g1z)
        else:
            g += GCode.from_points([(x, 0), (x, ty1 - 0.1)], g0z, g1z)
            g += GCode.from_points([(x, ty2 + 0.1), (x, h)], g0z, g1z)
    im = g.render(0, 0, 32, 6, 96)
    im.write_to_png('planets.png')
Esempio n. 2
0
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')
Esempio n. 3
0
def main():
    bit = 0.25
    mp = load_letters('MEGAN')
    mp = mp.buffer(-bit / 2)
    mps = []
    while not mp.is_empty:
        mps.append(mp)
        mp = mp.buffer(-bit / 2)
    g = GCode()
    for mp in mps:
        g += GCode.from_geometry(mp, G0Z, -0.21875 * 1.0)
    g = g.rotate(90).origin().translate(2, 0)
    g = HEADER + g + FOOTER
    im = g.render(0, 0, 6, 8, 96)
    im.write_to_png('megan.png')
    g.save('megan.nc')
Esempio n. 4
0
def main():
    bit = 0.125
    r = 0.21875
    d = 0.09375
    steps = 16
    cells = [
        cell(0, 0),
        cell(1, 0),
        cell(1, 1),
        cell(2, 1),
        cell(3, 1),
    ]
    mp = cascaded_union(cells).buffer(-bit).buffer(bit)
    g = GCode()
    for p in cells:
        g += GCode.from_geometry(p, G0Z, -d)
    # for p in cells:
    #     g += GCode.from_geometry(p, G0Z, -bit)
    for step in range(steps):
        p = step / (steps - 1.0)
        a = radians(p * 90)
        x = sin(a) * r
        b = x + bit / 2 - r
        z = r - (r * r - x * x) ** 0.5
        print '%.3f, %.3f, %.3f, %.3f' % (p, x, b, z)
        g += GCode.from_geometry(mp.buffer(b), G0Z, -z)
    # g += GCode.from_geometry(mp.buffer(bit / 2), G0Z, -0.4)
    # g += GCode.from_geometry(mp.buffer(bit / 2), G0Z, -0.7)
    # g += GCode.from_geometry(mp.buffer(bit / 2), G0Z, -0.6, bit + 0.1, 3)
    g += GCode.from_geometry(mp.buffer(bit / 2), G0Z, -0.4, bit + 0.2, 3.5)
    g = g.scale(-1, 1)
    g = g.origin().translate(0, 0.5)
    g = HEADER + g + FOOTER
    p = 0#0.5
    im = g.render(-p, -p, 6 + p, 6 + p, 96*4)
    im.write_to_png('blokus.png')
    g.save('blokus.nc')
Esempio n. 5
0
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))
Esempio n. 6
0
def create_face(dihedral, sides, length, depth, iterations):
    angle = radians((180 - dihedral) / 2)
    hyp = 1 / cos(angle) * depth
    max_offset = sin(angle) * hyp
    points = []
    for i in range(iterations):
        p = i / float(iterations - 1)
        offset = sin(angle) * p * hyp
        z = -cos(angle) * p * hyp
        p = create_points(sides, length, offset - max_offset)
        p = [(x, y, z) for x, y in p]
        points.extend(p)
    lines = []
    lines.append('G0 Z%f' % G0Z)
    lines.append('G0 X%f Y%f' % points[0][:2])
    for point in points:
        lines.append('G1 X%f Y%f Z%f' % point)
    lines.append('G0 Z%f' % G0Z)
    g = GCode(lines)
    g = g.origin()
    g = HEADER + g + FOOTER
    g.save('polyhedra.nc')
    im = g.render(0, 0, 6, 8, 96)
    im.write_to_png('polyhedra.png')
Esempio n. 7
0
def create_shape(sides, length):
    bit = 0.125
    size = 0.25
    offset = bit / 5
    data = [
        [0] * 5,
        # [1] * 5,
        # [0, 1, 0, 0, 1],
        # [1, 0, 1, 1, 0],
    ]
    # gs = GCode()
    for index, directions in enumerate(data):
        p = create_points(sides, length)
        # p = add_notches(p, size, offset, directions)
        # p = LineString(p).buffer(bit / 2).exterior.coords
        g = GCode()
        g += GCode.from_points(p, G0Z, -0.15)
        g += GCode.from_points(p, G0Z, -0.275)
        # g = g.move(3, 0, 0.5, 0)
        # gs += g
        g = HEADER + g + FOOTER
        g.save('solids%d.nc' % index)
        im = g.render(0, 0, 6, 8, 96)
        im.write_to_png('solids%d.png' % index)