Exemple #1
0
def slice_image():
    triangle = gdstk.regular_polygon((-10, 0), 8, 3)
    ring = gdstk.ellipse((10, 0), 8, 5, layer=1)
    result = gdstk.slice([triangle, ring], (-10, -5, 0, 6, 14), "x")
    # print(len(result))
    # print([len(polys) for polys in result])
    return gdstk.Cell("slice").add(*[p for polys in result for p in polys])
Exemple #2
0
def slice_image():
    triangle = gdstk.regular_polygon((-10, 0), 8, 3)
    ring = gdstk.ellipse((10, 0), 8, 5, layer=1)
    result = gdstk.slice([triangle, ring], (-10, -5, 0, 6, 14), "x")
    assert len(result) == 6
    assert all(len(polys) == s for polys, s in zip(result, [1, 1, 0, 1, 2, 1]))
    return gdstk.Cell("slice").add(*[p for polys in result for p in polys])
Exemple #3
0
    text = gdstk.text("GDSTK", 4, (0, 0))
    # Create a rectangle extending the text's bounding box by 1
    rect = gdstk.rectangle((-1, -1), (5 * 4 * 9 / 16 + 1, 4 + 1))

    # Subtract the text from the rectangle
    inv = gdstk.boolean(rect, text, "not")
    draw(gdstk.Cell("boolean_operations").add(*inv), path)

    # Slice Operation
    ring1 = gdstk.ellipse((-6, 0), 6, inner_radius=4)
    ring2 = gdstk.ellipse((0, 0), 6, inner_radius=4)
    ring3 = gdstk.ellipse((6, 0), 6, inner_radius=4)

    # Slice the first ring across x=-3, the second ring across x=-3
    # and x=3, and the third ring across x=3
    slices1 = gdstk.slice(ring1, -3, "x")
    slices2 = gdstk.slice(ring2, [-3, 3], "x")
    slices3 = gdstk.slice(ring3, 3, "x")

    slices = gdstk.Cell("SLICES")

    # Keep only the left side of slices1, the center part of slices2
    # and the right side of slices3
    slices.add(*slices1[0])
    slices.add(*slices2[1])
    slices.add(*slices3[1])
    # draw
    slices.name = "slice_operation"
    draw(slices, path)
    slices.name = "SLICES"