``k`` pin offsets evenly spread along a side of half-length ``half``, symmetric about the centre, ≥ ``_CORNER`` from each corner, on the grid. Spacing is a multiple of ``_STEP`` (so offsets stay on the grid for any pin count) and as wide as fits the side; it never drops below ``_STEP``.
(k: int, half: float)
| 128 | |
| 129 | |
| 130 | def _spread(k: int, half: float) -> list[float]: |
| 131 | """``k`` pin offsets evenly spread along a side of half-length ``half``, |
| 132 | symmetric about the centre, ≥ ``_CORNER`` from each corner, on the grid. |
| 133 | |
| 134 | Spacing is a multiple of ``_STEP`` (so offsets stay on the grid for any pin |
| 135 | count) and as wide as fits the side; it never drops below ``_STEP``.""" |
| 136 | if k <= 0: |
| 137 | return [] |
| 138 | if k == 1: |
| 139 | return [0.0] |
| 140 | avail = max(0.0, 2 * (half - _CORNER)) |
| 141 | step = max(_STEP, math.floor(avail / (k - 1) / _STEP) * _STEP) |
| 142 | return [(i - (k - 1) / 2) * step for i in range(k)] |
| 143 | |
| 144 | |
| 145 | def box_symbol_svg(defn: SubcktDef, placement: list | None = None, |