Courtyard of a footprint
64-bitThe rectangle around all pads, grown by a margin.
courtyard = (min(x − w ÷ 2) − m, min(y − h ÷ 2) − m, max(x + w ÷ 2) + m, max(y + h ÷ 2) + m)
Minimum and maximum over the pads' edges, then one subtraction or addition of the margin. No rounding.
/**
* Parametric footprints (0.8 XE.11). Land patterns here are EXAMPLES worked out from body and lead sizes with plain rules; they are not IPC-7351 values
* (that standard is not reproduced) — a shop's own library replaces them. Pad numbers are strings. Local origin = the part centre, pin 1 at the left/top.
*/
const mk = (name, pads, margin = 0.25, silk = []) => {
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
for (const p of pads) { x0 = Math.min(x0, p.x - p.w / 2); x1 = Math.max(x1, p.x + p.w / 2); y0 = Math.min(y0, p.y - p.h / 2); y1 = Math.max(y1, p.y + p.h / 2); }
return { name, pads, courtyard: [x0 - margin, y0 - margin, x1 + margin, y1 + margin], silk };
};