from case import gridify, shape2points, design header = "# Ref Val Package PosX PosY Rot Side" fmt = "{}{} * * {} {} {} {}" print(header) points = gridify(shape2points(design["shape"])) for i, (y, x) in enumerate(points, start=1): x += 26 y += 126 i = i - 3 if i <= 0: i += 48 + 3 d_rot = -90 rgb_rot = 0 if (i-1)%12 >= 6: d_rot += 180 if (i-1)%24 >= 12: rgb_rot += 180 print(fmt.format("S", i, x, -y, 0, "top")) print(fmt.format("D", i, x, -y - 9.5, d_rot, "bottom")) print(fmt.format("RGB", i, x, 4.7-y, rgb_rot, "top"))