circuit-json-to-lbrn 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +388 -374
- package/lib/ConvertContext.ts +3 -0
- package/lib/element-handlers/addPcbVia/index.ts +11 -2
- package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +9 -3
- package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +33 -30
- package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +13 -22
- package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +20 -4
- package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +32 -30
- package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +21 -8
- package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +32 -30
- package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +33 -38
- package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +27 -37
- package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +9 -29
- package/lib/element-handlers/addSmtPad/addRectSmtPad.ts +29 -51
- package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +27 -37
- package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +27 -37
- package/lib/helpers/addCopperGeometryToNetOrProject.ts +48 -0
- package/lib/index.ts +3 -0
- package/package.json +1 -1
- package/tests/basics/soldermask-margin/__snapshots__/negative-soldermask-margin.snap.svg +1 -1
- package/tests/basics/soldermask-margin/__snapshots__/percent-soldermask-margin.snap.svg +8 -0
- package/tests/basics/soldermask-margin/percent-soldermask-margin.test.ts +90 -0
- package/tests/examples/example02/__snapshots__/example02.snap.svg +1 -1
- package/tests/examples/example04/1206x4_3216metric.json +2973 -0
- package/tests/examples/example04/__snapshots__/example04.snap.svg +1 -0
- package/tests/examples/example04/example04.test.ts +32 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
3
|
+
import { generateLightBurnSvg } from "lbrnts"
|
|
4
|
+
import { convertCircuitJsonToLbrn } from "../../../lib"
|
|
5
|
+
import { stackSvgsVertically } from "stack-svgs"
|
|
6
|
+
import type { CircuitJson } from "circuit-json"
|
|
7
|
+
|
|
8
|
+
const circuitJson: CircuitJson = [
|
|
9
|
+
{
|
|
10
|
+
type: "pcb_board",
|
|
11
|
+
pcb_board_id: "board",
|
|
12
|
+
width: 200,
|
|
13
|
+
height: 200,
|
|
14
|
+
center: { x: 0, y: 0 },
|
|
15
|
+
thickness: 6,
|
|
16
|
+
num_layers: 2,
|
|
17
|
+
material: "fr4",
|
|
18
|
+
},
|
|
19
|
+
// Rect pad: 24mm x 12mm @ -10% → 21.6 x 10.8
|
|
20
|
+
{
|
|
21
|
+
type: "pcb_smtpad",
|
|
22
|
+
x: -70,
|
|
23
|
+
y: 50,
|
|
24
|
+
layer: "top",
|
|
25
|
+
shape: "rect",
|
|
26
|
+
pcb_smtpad_id: "rect_pad_narrow",
|
|
27
|
+
width: 24,
|
|
28
|
+
height: 12,
|
|
29
|
+
},
|
|
30
|
+
// Square rect pad: 30mm x 30mm @ -10% → 27 x 27
|
|
31
|
+
{
|
|
32
|
+
type: "pcb_smtpad",
|
|
33
|
+
x: -30,
|
|
34
|
+
y: 50,
|
|
35
|
+
layer: "top",
|
|
36
|
+
shape: "rect",
|
|
37
|
+
pcb_smtpad_id: "rect_pad_square",
|
|
38
|
+
width: 30,
|
|
39
|
+
height: 30,
|
|
40
|
+
},
|
|
41
|
+
// Pill pad: 36mm x 18mm @ -10% → 32.4 x 16.2
|
|
42
|
+
{
|
|
43
|
+
type: "pcb_smtpad",
|
|
44
|
+
x: 10,
|
|
45
|
+
y: 50,
|
|
46
|
+
layer: "top",
|
|
47
|
+
shape: "pill",
|
|
48
|
+
pcb_smtpad_id: "pill_pad",
|
|
49
|
+
width: 36,
|
|
50
|
+
height: 18,
|
|
51
|
+
radius: 9,
|
|
52
|
+
},
|
|
53
|
+
// Circle pad: radius 15mm → diameter 30mm @ -10% → 27mm
|
|
54
|
+
{
|
|
55
|
+
type: "pcb_smtpad",
|
|
56
|
+
x: 50,
|
|
57
|
+
y: 50,
|
|
58
|
+
layer: "top",
|
|
59
|
+
shape: "circle",
|
|
60
|
+
pcb_smtpad_id: "circle_pad",
|
|
61
|
+
radius: 15,
|
|
62
|
+
},
|
|
63
|
+
// Via: outer_diameter 30mm @ -10% → 27mm
|
|
64
|
+
{
|
|
65
|
+
type: "pcb_via",
|
|
66
|
+
pcb_via_id: "via",
|
|
67
|
+
x: -50,
|
|
68
|
+
y: -30,
|
|
69
|
+
outer_diameter: 30,
|
|
70
|
+
hole_diameter: 15,
|
|
71
|
+
layers: ["top", "bottom"],
|
|
72
|
+
},
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
test("soldermask renders with correct percent margin", async () => {
|
|
76
|
+
const pcbSvg = await convertCircuitJsonToPcbSvg(circuitJson)
|
|
77
|
+
|
|
78
|
+
const project = convertCircuitJsonToLbrn(circuitJson, {
|
|
79
|
+
includeSoldermask: true,
|
|
80
|
+
includeCopper: true,
|
|
81
|
+
solderMaskMarginPercent: -20, // negative shrink
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const lbrnSvg = await generateLightBurnSvg(project)
|
|
85
|
+
|
|
86
|
+
// Compare stacked SVGs visually to ensure soldermask scaling matches percent margin
|
|
87
|
+
expect(stackSvgsVertically([pcbSvg, lbrnSvg])).toMatchSvgSnapshot(
|
|
88
|
+
import.meta.filename,
|
|
89
|
+
)
|
|
90
|
+
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="400" viewBox="-2.3 -4.15 10 10" style="background-color: white;"><rect x="-2.3" y="-4.15" width="10" height="10" fill="white"/><g transform="matrix(1 0 0 -1 0 1.6999999999999993)"><g transform="matrix(1,0,0,1,0,0)"><path d="M 5.2 0.85 L 5.197592363336098 0.8990085701647803 L 5.190392640201615 0.9475451610080641 L 5.178470167866105 0.9951423386272311 L 5.161939766255643 1.041341716182545 L 5.140960632174178 1.0856983684129988 L 5.115734806151273 1.1277851165098012 L 5.086505226681369 1.1671966420818227 L 5.053553390593274 1.2035533905932736 L 5.017196642081823 1.2365052266813685 L 4.977785116509802 1.2657348061512725 L 4.935698368412999 1.2909606321741776 L 4.891341716182545 1.3119397662556433 L 4.845142338627231 1.3284701678661044 L 4.797545161008064 1.3403926402016153 L 4.74900857016478 1.3475923633360984 L 4.7 1.35 L 4.65099142983522 1.3475923633360984 L 4.602454838991936 1.3403926402016153 L 4.554857661372769 1.3284701678661044 L 4.508658283817455 1.3119397662556433 L 4.464301631587001 1.2909606321741776 L 4.4222148834901995 1.2657348061512725 L 4.382803357918178 1.2365052266813685 L 4.346446609406726 1.2035533905932738 L 4.313494773318632 1.1671966420818227 L 4.284265193848728 1.1277851165098012 L 4.259039367825823 1.0856983684129988 L 4.238060233744357 1.041341716182545 L 4.221529832133895 0.9951423386272311 L 4.209607359798385 0.9475451610080643 L 4.202407636663902 0.8990085701647804 L 4.2 0.8500000000000001 L 4.202407636663902 0.8009914298352196 L 4.209607359798385 0.7524548389919358 L 4.221529832133895 0.704857661372769 L 4.238060233744357 0.6586582838174552 L 4.259039367825823 0.6143016315870011 L 4.284265193848728 0.572214883490199 L 4.313494773318632 0.5328033579181773 L 4.346446609406726 0.49644660940672625 L 4.382803357918177 0.46349477331863165 L 4.422214883490199 0.43426519384872736 L 4.464301631587001 0.4090393678258225 L 4.508658283817455 0.3880602337443567 L 4.554857661372769 0.37152983213389557 L 4.602454838991936 0.3596073597983848 L 4.65099142983522 0.3524076366639015 L 4.7 0.35 L 4.74900857016478 0.3524076366639015 L 4.797545161008064 0.35960735979838476 L 4.845142338627231 0.3715298321338955 L 4.891341716182545 0.38806023374435666 L 4.935698368412999 0.40903936782582245 L 4.977785116509801 0.43426519384872725 L 5.017196642081823 0.46349477331863154 L 5.053553390593274 0.49644660940672614 L 5.086505226681369 0.532803357918177 L 5.115734806151273 0.5722148834901989 L 5.140960632174178 0.614301631587001 L 5.161939766255643 0.6586582838174548 L 5.178470167866105 0.7048576613727687 L 5.190392640201615 0.7524548389919357 L 5.197592363336098 0.8009914298352198 L 5.2 0.85 L 5.2 0.85 Z" fill="none" stroke="#FF0000" stroke-width="0.01" stroke-linecap="round" stroke-linejoin="round"/></g><g transform="matrix(1,0,0,1,0,0)"><path d="M -2.3 -4.15 L 7.7 -4.15 L 7.7 5.85 L -2.3 5.85 L -2.3 -4.15 L -2.3 -4.15 Z" fill="none" stroke="#FF0000" stroke-width="0.01" stroke-linecap="round" stroke-linejoin="round"/></g><g transform="matrix(1,0,0,1,0,0)"><path d="M 1.
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="400" viewBox="-2.3 -4.15 10 10" style="background-color: white;"><rect x="-2.3" y="-4.15" width="10" height="10" fill="white"/><g transform="matrix(1 0 0 -1 0 1.6999999999999993)"><g transform="matrix(1,0,0,1,0,0)"><path d="M 5.2 0.85 L 5.197592363336098 0.8990085701647803 L 5.190392640201615 0.9475451610080641 L 5.178470167866105 0.9951423386272311 L 5.161939766255643 1.041341716182545 L 5.140960632174178 1.0856983684129988 L 5.115734806151273 1.1277851165098012 L 5.086505226681369 1.1671966420818227 L 5.053553390593274 1.2035533905932736 L 5.017196642081823 1.2365052266813685 L 4.977785116509802 1.2657348061512725 L 4.935698368412999 1.2909606321741776 L 4.891341716182545 1.3119397662556433 L 4.845142338627231 1.3284701678661044 L 4.797545161008064 1.3403926402016153 L 4.74900857016478 1.3475923633360984 L 4.7 1.35 L 4.65099142983522 1.3475923633360984 L 4.602454838991936 1.3403926402016153 L 4.554857661372769 1.3284701678661044 L 4.508658283817455 1.3119397662556433 L 4.464301631587001 1.2909606321741776 L 4.4222148834901995 1.2657348061512725 L 4.382803357918178 1.2365052266813685 L 4.346446609406726 1.2035533905932738 L 4.313494773318632 1.1671966420818227 L 4.284265193848728 1.1277851165098012 L 4.259039367825823 1.0856983684129988 L 4.238060233744357 1.041341716182545 L 4.221529832133895 0.9951423386272311 L 4.209607359798385 0.9475451610080643 L 4.202407636663902 0.8990085701647804 L 4.2 0.8500000000000001 L 4.202407636663902 0.8009914298352196 L 4.209607359798385 0.7524548389919358 L 4.221529832133895 0.704857661372769 L 4.238060233744357 0.6586582838174552 L 4.259039367825823 0.6143016315870011 L 4.284265193848728 0.572214883490199 L 4.313494773318632 0.5328033579181773 L 4.346446609406726 0.49644660940672625 L 4.382803357918177 0.46349477331863165 L 4.422214883490199 0.43426519384872736 L 4.464301631587001 0.4090393678258225 L 4.508658283817455 0.3880602337443567 L 4.554857661372769 0.37152983213389557 L 4.602454838991936 0.3596073597983848 L 4.65099142983522 0.3524076366639015 L 4.7 0.35 L 4.74900857016478 0.3524076366639015 L 4.797545161008064 0.35960735979838476 L 4.845142338627231 0.3715298321338955 L 4.891341716182545 0.38806023374435666 L 4.935698368412999 0.40903936782582245 L 4.977785116509801 0.43426519384872725 L 5.017196642081823 0.46349477331863154 L 5.053553390593274 0.49644660940672614 L 5.086505226681369 0.532803357918177 L 5.115734806151273 0.5722148834901989 L 5.140960632174178 0.614301631587001 L 5.161939766255643 0.6586582838174548 L 5.178470167866105 0.7048576613727687 L 5.190392640201615 0.7524548389919357 L 5.197592363336098 0.8009914298352198 L 5.2 0.85 L 5.2 0.85 Z" fill="none" stroke="#FF0000" stroke-width="0.01" stroke-linecap="round" stroke-linejoin="round"/></g><g transform="matrix(1,0,0,1,0,0)"><path d="M -2.3 -4.15 L 7.7 -4.15 L 7.7 5.85 L -2.3 5.85 L -2.3 -4.15 L -2.3 -4.15 Z" fill="none" stroke="#FF0000" stroke-width="0.01" stroke-linecap="round" stroke-linejoin="round"/></g><g transform="matrix(1,0,0,1,0,0)"><path d="M 1.2947093185218244 0.9249999999999999 L 1.2884711682419385 0.9670541932096769 L 1.2741642014393255 1.0241708063526773 L 1.2543277195067724 1.0796100594190539 L 1.2291527586090132 1.1328380420955986 L 1.1988817673815273 1.1833421398117614 L 1.1638062720176423 1.2306359704981873 L 1.1242640687119287 1.2742640687119284 L 1.0806359704981874 1.3138062720176422 L 1.0333421398117615 1.3488817673815272 L 0.9828380420955989 1.3791527586090129 L 0.9296100594190541 1.404327719506772 L 0.8741708063526776 1.4241642014393252 L 0.8170541932096772 1.4384711682419382 L 0.7588102841977367 1.447110836003318 L 0.7000000000000002 1.45 L 0.6411897158022638 1.447110836003318 L 0.5829458067903233 1.4384711682419382 L 0.525829193647323 1.4241642014393254 L 0.47038994058094635 1.404327719506772 L 0.4171619579044016 1.3791527586090129 L 0.36665786018823904 1.3488817673815272 L 0.319364029501813 1.3138062720176422 L 0.2757359312880717 1.2742640687119284 L 0.236193727982358 1.2306359704981873 L 0.201118232618473 1.1833421398117614 L 0.17084724139098728 1.1328380420955986 L 0.1456722804932281 1.0796100594190539 L 0.12583579856067495 1.0241708063526773 L 0.11152883175806194 0.9670541932096771 L 0.10288916399668213 0.9088102841977365 L 0.1000000000000002 0.8500000000000001 L 0.10288916399668202 0.7911897158022636 L 0.11152883175806194 0.732945806790323 L 0.12583579856067484 0.6758291936473227 L 0.1456722804932281 0.6203899405809462 L 0.17084724139098717 0.5671619579044014 L 0.20111823261847295 0.5166578601882388 L 0.23619372798235794 0.46936402950181283 L 0.27573593128807156 0.4257359312880715 L 0.3193640295018127 0.386193727982358 L 0.36665786018823887 0.35111823261847286 L 0.4171619579044014 0.3208472413909871 L 0.47038994058094596 0.29567228049322813 L 0.5258291936473227 0.27583579856067475 L 0.582945806790323 0.26152883175806185 L 0.6411897158022639 0.2528891639966818 L 0.7000000000000001 0.25 L 0.7588102841977362 0.2528891639966818 L 0.8170541932096771 0.26152883175806174 L 0.8741708063526774 0.27583579856067464 L 0.9296100594190542 0.295672280493228 L 0.9828380420955987 0.32084724139098697 L 1.0333421398117613 0.35111823261847275 L 1.0806359704981876 0.38619372798235785 L 1.1242640687119285 0.42573593128807136 L 1.163806272017642 0.46936402950181244 L 1.1988817673815273 0.5166578601882387 L 1.229152758609013 0.5671619579044012 L 1.254327719506772 0.6203899405809458 L 1.2741642014393255 0.6758291936473225 L 1.2884711682419383 0.7329458067903227 L 1.2947093185218246 0.775 L 2.62 0.775 L 2.62 0.77 L 3.9578793122685734 0.77 L 3.9644110396975774 0.7036822584879037 L 4.007090350616535 0.5629874257261827 L 4.0763977907730915 0.4333223252352985 L 4.16966991411009 0.3196699141100894 L 4.283322325235298 0.22639779077309108 L 4.4129874257261825 0.1570903506165351 L 4.553682258487903 0.11441103969757727 L 4.7 0.09999999999999998 L 4.846317741512096 0.11441103969757715 L 4.987012574273818 0.15709035061653498 L 5.116677674764702 0.22639779077309086 L 5.230330085889911 0.31966991411008927 L 5.323602209226909 0.43332232523529834 L 5.392909649383465 0.5629874257261822 L 5.435588960302423 0.7036822584879034 L 5.45 0.85 L 5.4355889603024234 0.9963177415120962 L 5.392909649383466 1.1370125742738173 L 5.323602209226909 1.2666776747647015 L 5.230330085889911 1.3803300858899106 L 5.116677674764702 1.4736022092269088 L 4.987012574273818 1.542909649383465 L 4.846317741512096 1.585588960302423 L 4.7 1.6 L 4.553682258487904 1.585588960302423 L 4.4129874257261825 1.542909649383465 L 4.283322325235298 1.473602209226909 L 4.16966991411009 1.3803300858899106 L 4.0763977907730915 1.2666776747647015 L 4.007090350616535 1.1370125742738173 L 3.9644110396975774 0.9963177415120964 L 3.9578793122685734 0.9299999999999999 L 2.7800000000000002 0.9299999999999999 L 2.7800000000000002 2.77 L 4.106032361415868 2.77 L 4.111528831758062 2.732945806790323 L 4.125835798560675 2.675829193647323 L 4.145672280493228 2.6203899405809463 L 4.170847241390987 2.5671619579044016 L 4.201118232618473 2.516657860188239 L 4.236193727982358 2.469364029501813 L 4.275735931288072 2.4257359312880715 L 4.319364029501813 2.386193727982358 L 4.366657860188239 2.351118232618473 L 4.417161957904401 2.3208472413909873 L 4.470389940580946 2.2956722804932284 L 4.525829193647323 2.2758357985606747 L 4.582945806790323 2.2615288317580617 L 4.6411897158022635 2.2528891639966817 L 4.7 2.25 L 4.758810284197736 2.2528891639966817 L 4.817054193209677 2.2615288317580617 L 4.874170806352677 2.2758357985606747 L 4.929610059419054 2.2956722804932284 L 4.982838042095599 2.320847241390987 L 5.0333421398117615 2.351118232618473 L 5.080635970498188 2.386193727982358 L 5.124264068711929 2.4257359312880715 L 5.163806272017642 2.4693640295018127 L 5.198881767381527 2.516657860188239 L 5.229152758609013 2.567161957904401 L 5.254327719506772 2.620389940580946 L 5.2741642014393255 2.6758291936473224 L 5.288471168241938 2.732945806790323 L 5.297110836003318 2.791189715802264 L 5.3 2.85 L 5.297110836003318 2.9088102841977364 L 5.288471168241938 2.9670541932096772 L 5.2741642014393255 3.0241708063526773 L 5.254327719506772 3.079610059419054 L 5.229152758609013 3.1328380420955986 L 5.198881767381527 3.1833421398117614 L 5.163806272017642 3.2306359704981875 L 5.124264068711929 3.2742640687119287 L 5.080635970498188 3.313806272017642 L 5.0333421398117615 3.348881767381527 L 4.982838042095599 3.379152758609013 L 4.929610059419054 3.4043277195067723 L 4.874170806352677 3.4241642014393254 L 4.817054193209677 3.4384711682419384 L 4.758810284197737 3.447110836003318 L 4.7 3.45 L 4.6411897158022635 3.4471108360033185 L 4.582945806790323 3.4384711682419384 L 4.525829193647323 3.4241642014393254 L 4.470389940580946 3.4043277195067723 L 4.417161957904401 3.3791527586090133 L 4.366657860188239 3.348881767381527 L 4.319364029501813 3.313806272017642 L 4.275735931288072 3.2742640687119287 L 4.236193727982358 3.2306359704981875 L 4.201118232618473 3.1833421398117614 L 4.170847241390987 3.1328380420955986 L 4.145672280493228 3.079610059419054 L 4.125835798560675 3.0241708063526773 L 4.111528831758062 2.9670541932096772 L 4.106032361415868 2.93 L 2.62 2.93 L 2.62 0.9249999999999999 L 1.2947093185218244 0.9249999999999999 L 1.2947093185218244 0.9249999999999999" fill="none" stroke="#000000" stroke-width="0.01" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>
|