"""Write the tutorial GDS files in the current directory using KLayout."""

import klayout.db as kdb

for name, width, gap in (
    ("violations", 100, 150),
    ("corrected", 200, 300),
):
    layout = kdb.Layout()
    layout.dbu = 0.001  # Micrometres per database unit: a 1 nm grid.
    top = layout.create_cell(name.upper())
    metal = layout.layer(10, 0)

    # An isolated strip: 2 um long; 0.1 um or 0.2 um wide.
    top.shapes(metal).insert(kdb.Box(0, 0, 2000, width))

    # Two 2 x 0.5 um strips, separated by 0.15 um or 0.3 um.
    top.shapes(metal).insert(kdb.Box(0, 1000, 2000, 1500))
    top.shapes(metal).insert(kdb.Box(0, 1500 + gap, 2000, 2000 + gap))

    layout.write(f"{name}.gds")
