From 80f2cb69ae2157fb90a7c70a7bdff1f24c0f8fe4 Mon Sep 17 00:00:00 2001 From: victorjzq <118996546+victorjzq@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:16:35 +0700 Subject: [PATCH 1/2] feat: add courtyard to MELF, MICROMELF, and MINIMELF footprints --- src/fn/melf.ts | 25 ++++++++++++++++++++++++- src/fn/micromelf.ts | 25 ++++++++++++++++++++++++- src/fn/minimelf.ts | 25 ++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/fn/melf.ts b/src/fn/melf.ts index 036905c3..23fc0f6f 100644 --- a/src/fn/melf.ts +++ b/src/fn/melf.ts @@ -1,4 +1,8 @@ -import type { AnySoupElement, PcbSilkscreenPath } from "circuit-json" +import type { + AnySoupElement, + PcbCourtyardRect, + PcbSilkscreenPath, +} from "circuit-json" import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" @@ -53,10 +57,29 @@ export const melf = ( pcb_silkscreen_path_id: "", } + const h = length.parse(parameters.h) + const pl = length.parse(parameters.pl) + const p = length.parse(parameters.p) + const courtyardPadding = 0.25 + const crtMinX = -(p / 2 + pl / 2) - courtyardPadding + const crtMaxX = p / 2 + pl / 2 + courtyardPadding + const crtMinY = -h / 2 - courtyardPadding + const crtMaxY = h / 2 + courtyardPadding + const courtyard: PcbCourtyardRect = { + type: "pcb_courtyard_rect", + pcb_courtyard_rect_id: "", + pcb_component_id: "", + center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 }, + width: crtMaxX - crtMinX, + height: crtMaxY - crtMinY, + layer: "top", + } + return { circuitJson: melfWithoutParsing(parameters).concat( silkscreenLine as AnySoupElement, silkscreenRefText as AnySoupElement, + courtyard as AnySoupElement, ), parameters, } diff --git a/src/fn/micromelf.ts b/src/fn/micromelf.ts index 183d00aa..d1ce725b 100644 --- a/src/fn/micromelf.ts +++ b/src/fn/micromelf.ts @@ -1,4 +1,8 @@ -import type { AnySoupElement, PcbSilkscreenPath } from "circuit-json" +import type { + AnySoupElement, + PcbCourtyardRect, + PcbSilkscreenPath, +} from "circuit-json" import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" @@ -53,10 +57,29 @@ export const micromelf = ( pcb_silkscreen_path_id: "", } + const h = length.parse(parameters.h) + const pl = length.parse(parameters.pl) + const p = length.parse(parameters.p) + const courtyardPadding = 0.25 + const crtMinX = -(p / 2 + pl / 2) - courtyardPadding + const crtMaxX = p / 2 + pl / 2 + courtyardPadding + const crtMinY = -h / 2 - courtyardPadding + const crtMaxY = h / 2 + courtyardPadding + const courtyard: PcbCourtyardRect = { + type: "pcb_courtyard_rect", + pcb_courtyard_rect_id: "", + pcb_component_id: "", + center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 }, + width: crtMaxX - crtMinX, + height: crtMaxY - crtMinY, + layer: "top", + } + return { circuitJson: microMelfWithoutParsing(parameters).concat( silkscreenLine as AnySoupElement, silkscreenRefText as AnySoupElement, + courtyard as AnySoupElement, ), parameters, } diff --git a/src/fn/minimelf.ts b/src/fn/minimelf.ts index f4130954..659bb05d 100644 --- a/src/fn/minimelf.ts +++ b/src/fn/minimelf.ts @@ -1,4 +1,8 @@ -import type { AnySoupElement, PcbSilkscreenPath } from "circuit-json" +import type { + AnySoupElement, + PcbCourtyardRect, + PcbSilkscreenPath, +} from "circuit-json" import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" @@ -53,10 +57,29 @@ export const minimelf = ( pcb_silkscreen_path_id: "", } + const h = length.parse(parameters.h) + const pl = length.parse(parameters.pl) + const p = length.parse(parameters.p) + const courtyardPadding = 0.25 + const crtMinX = -(p / 2 + pl / 2) - courtyardPadding + const crtMaxX = p / 2 + pl / 2 + courtyardPadding + const crtMinY = -h / 2 - courtyardPadding + const crtMaxY = h / 2 + courtyardPadding + const courtyard: PcbCourtyardRect = { + type: "pcb_courtyard_rect", + pcb_courtyard_rect_id: "", + pcb_component_id: "", + center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 }, + width: crtMaxX - crtMinX, + height: crtMaxY - crtMinY, + layer: "top", + } + return { circuitJson: miniMelfWithoutParsing(parameters).concat( silkscreenLine as AnySoupElement, silkscreenRefText as AnySoupElement, + courtyard as AnySoupElement, ), parameters, } From eee690afdef59168138afd367cf1b5fd98305330 Mon Sep 17 00:00:00 2001 From: Zhiqiang Jia Date: Thu, 19 Mar 2026 21:06:54 +0700 Subject: [PATCH 2/2] test: update SVG snapshots for MELF, MINIMELF, MICROMELF courtyards --- tests/kicad-parity/__snapshots__/melf.snap.svg | 2 +- tests/kicad-parity/__snapshots__/micromelf.snap.svg | 2 +- tests/kicad-parity/__snapshots__/minimelf.snap.svg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/kicad-parity/__snapshots__/melf.snap.svg b/tests/kicad-parity/__snapshots__/melf.snap.svg index 027f8de5..de44ff78 100644 --- a/tests/kicad-parity/__snapshots__/melf.snap.svg +++ b/tests/kicad-parity/__snapshots__/melf.snap.svg @@ -1 +1 @@ -{REF}Diff: 0.00% \ No newline at end of file +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/micromelf.snap.svg b/tests/kicad-parity/__snapshots__/micromelf.snap.svg index 3e8f0640..6acbcd5a 100644 --- a/tests/kicad-parity/__snapshots__/micromelf.snap.svg +++ b/tests/kicad-parity/__snapshots__/micromelf.snap.svg @@ -1 +1 @@ -{REF}Diff: 0.00% \ No newline at end of file +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/minimelf.snap.svg b/tests/kicad-parity/__snapshots__/minimelf.snap.svg index 2f912989..b188ca79 100644 --- a/tests/kicad-parity/__snapshots__/minimelf.snap.svg +++ b/tests/kicad-parity/__snapshots__/minimelf.snap.svg @@ -1 +1 @@ -{REF}Diff: 0.00% \ No newline at end of file +{REF}Diff: 0.00% \ No newline at end of file