コード例 #1
0
ファイル: planets.py プロジェクト: fogleman/Carolina
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')
コード例 #2
0
ファイル: coaster.py プロジェクト: fogleman/Carolina
def coaster(style, side, corner_radius, circle_diameter, circle_depth, depth, bit):
    n = 120
    points = filled_circle(circle_diameter / 2.0 - bit / 2.0, n, bit / 4.0)
    g = GCode.from_points(points, G0Z, -circle_depth)
    if style == 1:
        points = rounded_square(side + bit, corner_radius)
    elif style == 2:
        points = circle(side / 2.0, n)
    elif style == 3:
        points = rounded_polygon(6, side / 2.0, corner_radius)
    elif style == 4:
        points = wavy_circle(side / 2.0, 360, 0.2, 7)
    else:
        raise Exception('invalid style')
    g += GCode.from_points(points, G0Z, -depth).multipass(G0Z, -depth, bit)
    return g.origin()
コード例 #3
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')
コード例 #4
0
ファイル: solids.py プロジェクト: fogleman/Carolina
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)
コード例 #5
0
ファイル: engrave.py プロジェクト: fogleman/Carolina
def main():
    sep = GCode.from_points([(3, 0), (3, 8)], 0.2, -0.05)

    t1 = GCode.from_file('text/Planet Earth.nc')
    t2 = GCode.from_file('text/Lambert Azimuthal Equal-Area.nc')
    t3 = GCode.from_file('text/0 N 110 W.nc')
    t4 = GCode.from_file('text/Michael Fogleman.nc')
    t5 = GCode.from_file('text/July 2015.nc')

    t1 = t1.scale(1.25, 1.25)
    t2 = t2.scale(0.55, 0.55)
    t3 = t3.scale(0.55, 0.55)

    t1 = t1.move(0, 0, 0.5, 0.5).depth(0.2, -0.07)
    t2 = t2.move(0, 0, 0.5, 0.5).depth(0.2, -0.03)
    t3 = t3.move(0, 0, 0.5, 0.5).depth(0.2, -0.03)
    t4 = t4.move(0, 0, 0.5, 0.5).depth(0.2, -0.05)
    t5 = t5.move(0, 0, 0.5, 0.5).depth(0.2, -0.05)

    t1 = t1.translate(0, 6.5)
    t2 = t2.translate(0, 5)
    t3 = t3.translate(0, 4)
    t4 = t4.translate(0, 2)
    t5 = t5.translate(0, 0)

    t = t1 + t2 + t3
    b = t4 + t5
    s = 2.0 / 3.0
    t = t.scale(s, s)
    b = b.scale(s, s)
    t = t.rotate(90)
    b = b.rotate(90)
    t = t.move(1.5, 4, 0.5, 0.5)
    b = b.move(4.5, 4, 0.5, 0.5)
    t = t + b
    t = t + sep
    t = HEADER + t + FOOTER
    p = 0.25
    im = t.render(0-p, 0-p, 6+p, 8+p, 96)
    im.write_to_png('engrave.png')
    t.save('engrave.nc')