from typing import Tuple

import pp
from pp.component import Component
from pp.components.rectangle import rectangle


@pp.cell_with_validator
def litho_star(
    num_lines: int = 20,
    line_width: float = 2.0,
    diameter: float = 200.0,
    layer: Tuple[int, int] = (1, 0),
) -> Component:
    """Creates a circular-star shape from lines, used as a lithographic
    resolution test pattern

    .. plot::
      :include-source:

      import pp

      c = pp.components.litho_star()
      c.plot()
    """
    D = Component()

    degree = 180 / num_lines
    R1 = rectangle(size=(line_width, diameter), layer=layer)
    for i in range(num_lines):
        r1 = D.add_ref(R1).rotate(degree * i)
        r1.center = (0, 0)

    return D


if __name__ == "__main__":

    c = litho_star()
    c.show()
