circuit-json-to-tscircuit 0.0.33 → 0.0.35
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/{chunk-ACNYSYBF.js → chunk-WC7XDXUV.js} +86 -7
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-footprint-tsx/convert-silkscreen-text.ts +8 -1
- package/lib/generate-symbol-tsx.ts +95 -1
- package/package.json +1 -1
- package/tests/__snapshots__/test4-support-silkscreen-pcb.snap.svg +1 -0
- package/tests/__snapshots__/test7-support-schematic-elements-comprehensive-schematic-symbol.snap.svg +2 -2
- package/tests/test4-support-silkscreen.test.tsx +79 -6
- package/tests/test7-support-schematic-elements.test.tsx +84 -19
|
@@ -477,14 +477,17 @@ var convertSilkscreen = (circuitJson) => {
|
|
|
477
477
|
|
|
478
478
|
// lib/generate-footprint-tsx/convert-silkscreen-text.ts
|
|
479
479
|
import { su as su10 } from "@tscircuit/soup-util";
|
|
480
|
+
import { mmStr as mmStr4 } from "@tscircuit/mm";
|
|
480
481
|
var convertSilkscreenText = (circuitJson) => {
|
|
481
482
|
const silkscreenTexts = su10(circuitJson).pcb_silkscreen_text.list();
|
|
482
483
|
const elementStrings = [];
|
|
483
484
|
for (const silkscreenText of silkscreenTexts) {
|
|
484
485
|
const pcbX = silkscreenText.anchor_position?.x ?? 0;
|
|
485
486
|
const pcbY = silkscreenText.anchor_position?.y ?? 0;
|
|
487
|
+
const knockoutPadding = silkscreenText.knockout_padding;
|
|
488
|
+
const hasUniformKnockoutPadding = knockoutPadding && knockoutPadding.left === knockoutPadding.top && knockoutPadding.top === knockoutPadding.right && knockoutPadding.right === knockoutPadding.bottom;
|
|
486
489
|
elementStrings.push(
|
|
487
|
-
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}} text="${escapeJsxText(silkscreenText.text)}" />`
|
|
490
|
+
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== void 0 ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== void 0 ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== void 0 ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? hasUniformKnockoutPadding ? ` knockoutPadding="${mmStr4(knockoutPadding.left)}"` : ` knockoutPaddingLeft="${mmStr4(knockoutPadding.left)}" knockoutPaddingTop="${mmStr4(knockoutPadding.top)}" knockoutPaddingRight="${mmStr4(knockoutPadding.right)}" knockoutPaddingBottom="${mmStr4(knockoutPadding.bottom)}"` : ""}${silkscreenText.is_mirrored !== void 0 ? ` mirrored={${silkscreenText.is_mirrored}}` : ""}${silkscreenText.layer !== void 0 ? ` layer="${silkscreenText.layer}"` : ""} text="${escapeJsxText(silkscreenText.text)}" />`
|
|
488
491
|
);
|
|
489
492
|
}
|
|
490
493
|
return elementStrings;
|
|
@@ -492,22 +495,22 @@ var convertSilkscreenText = (circuitJson) => {
|
|
|
492
495
|
|
|
493
496
|
// lib/generate-footprint-tsx/convert-smt-pads.ts
|
|
494
497
|
import { su as su11 } from "@tscircuit/soup-util";
|
|
495
|
-
import { mmStr as
|
|
498
|
+
import { mmStr as mmStr5 } from "@tscircuit/mm";
|
|
496
499
|
var convertSmtPads = (circuitJson) => {
|
|
497
500
|
const smtPads = su11(circuitJson).pcb_smtpad.list();
|
|
498
501
|
const elementStrings = [];
|
|
499
502
|
for (const smtPad of smtPads) {
|
|
500
503
|
if (smtPad.shape === "circle") {
|
|
501
504
|
elementStrings.push(
|
|
502
|
-
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${
|
|
505
|
+
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr5(smtPad.x)}" pcbY="${mmStr5(smtPad.y)}" radius="${mmStr5(smtPad.radius)}" shape="circle" />`
|
|
503
506
|
);
|
|
504
507
|
} else if (smtPad.shape === "rect") {
|
|
505
508
|
elementStrings.push(
|
|
506
|
-
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${
|
|
509
|
+
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr5(smtPad.x)}" pcbY="${mmStr5(smtPad.y)}" width="${mmStr5(smtPad.width)}" height="${mmStr5(smtPad.height)}" shape="rect" />`
|
|
507
510
|
);
|
|
508
511
|
} else if (smtPad.shape === "pill") {
|
|
509
512
|
elementStrings.push(
|
|
510
|
-
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${
|
|
513
|
+
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr5(smtPad.x)}" pcbY="${mmStr5(smtPad.y)}" width="${mmStr5(smtPad.width)}" height="${mmStr5(smtPad.height)}" radius="${mmStr5(smtPad.radius)}" shape="pill" />`
|
|
511
514
|
);
|
|
512
515
|
} else if (smtPad.shape === "polygon") {
|
|
513
516
|
elementStrings.push(
|
|
@@ -515,7 +518,7 @@ var convertSmtPads = (circuitJson) => {
|
|
|
515
518
|
);
|
|
516
519
|
} else if (smtPad.shape === "rotated_rect") {
|
|
517
520
|
elementStrings.push(
|
|
518
|
-
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${
|
|
521
|
+
`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr5(smtPad.x)}" pcbY="${mmStr5(smtPad.y)}" width="${mmStr5(smtPad.width)}" height="${mmStr5(smtPad.height)}" ccwRotation={${smtPad.ccw_rotation}} shape="rotated_rect" />`
|
|
519
522
|
);
|
|
520
523
|
}
|
|
521
524
|
}
|
|
@@ -550,6 +553,7 @@ var generateFootprintTsx = (circuitJson) => {
|
|
|
550
553
|
|
|
551
554
|
// lib/generate-symbol-tsx.ts
|
|
552
555
|
import { su as su12 } from "@tscircuit/soup-util";
|
|
556
|
+
var escapeJsxText2 = (text) => text.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
553
557
|
var generateSymbolTsx = (circuitJson) => {
|
|
554
558
|
const schematicArcs = su12(circuitJson).schematic_arc.list();
|
|
555
559
|
const schematicLines = su12(circuitJson).schematic_line.list();
|
|
@@ -558,6 +562,8 @@ var generateSymbolTsx = (circuitJson) => {
|
|
|
558
562
|
const schematicCircles = su12(circuitJson).schematic_circle.list();
|
|
559
563
|
const schematicBoxes = su12(circuitJson).schematic_box.list();
|
|
560
564
|
const schematicRects = su12(circuitJson).schematic_rect.list();
|
|
565
|
+
const schematicTables = su12(circuitJson).schematic_table.list();
|
|
566
|
+
const schematicTableCells = su12(circuitJson).schematic_table_cell.list();
|
|
561
567
|
const elementStrings = [];
|
|
562
568
|
for (const arc of schematicArcs) {
|
|
563
569
|
const center = arc.center ?? { x: 0, y: 0 };
|
|
@@ -656,7 +662,7 @@ var generateSymbolTsx = (circuitJson) => {
|
|
|
656
662
|
const x = text.position?.x ?? 0;
|
|
657
663
|
const y = text.position?.y ?? 0;
|
|
658
664
|
const rawText = String(text.text ?? "");
|
|
659
|
-
const escapedText = rawText
|
|
665
|
+
const escapedText = escapeJsxText2(rawText);
|
|
660
666
|
const anchorAlignment = text.anchor ?? "center";
|
|
661
667
|
const fontSize = text.font_size ?? 0.1;
|
|
662
668
|
const color = text.color ?? "black";
|
|
@@ -677,6 +683,79 @@ var generateSymbolTsx = (circuitJson) => {
|
|
|
677
683
|
`<schematiccircle center={{ x: ${x}, y: ${y} }} radius={${radius}} strokeWidth={${strokeWidth}} color="${color}" isFilled={${isFilled}} isDashed={${isDashed}} />`
|
|
678
684
|
);
|
|
679
685
|
}
|
|
686
|
+
for (const table of schematicTables) {
|
|
687
|
+
const tableCells = schematicTableCells.filter((cell) => cell.schematic_table_id === table.schematic_table_id).sort((a, b) => {
|
|
688
|
+
if (a.start_row_index !== b.start_row_index) {
|
|
689
|
+
return a.start_row_index - b.start_row_index;
|
|
690
|
+
}
|
|
691
|
+
return a.start_column_index - b.start_column_index;
|
|
692
|
+
});
|
|
693
|
+
const rowCount = table.row_heights.length;
|
|
694
|
+
const rowStrings = [];
|
|
695
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
696
|
+
const rowHeight = table.row_heights[rowIndex];
|
|
697
|
+
const rowCells = tableCells.filter(
|
|
698
|
+
(cell) => cell.start_row_index === rowIndex
|
|
699
|
+
);
|
|
700
|
+
const cellStrings = [];
|
|
701
|
+
for (const cell of rowCells) {
|
|
702
|
+
const rowSpan = cell.end_row_index - cell.start_row_index + 1;
|
|
703
|
+
const colSpan = cell.end_column_index - cell.start_column_index + 1;
|
|
704
|
+
const columnWidths = table.column_widths.slice(
|
|
705
|
+
cell.start_column_index,
|
|
706
|
+
cell.end_column_index + 1
|
|
707
|
+
);
|
|
708
|
+
const averageColumnWidth = columnWidths.length > 0 ? columnWidths.reduce((sum, width) => sum + width, 0) / columnWidths.length : cell.width / Math.max(colSpan, 1);
|
|
709
|
+
const props = [];
|
|
710
|
+
const text = cell.text ?? "";
|
|
711
|
+
if (text.length > 0) {
|
|
712
|
+
props.push(`text="${escapeJsxText2(text)}"`);
|
|
713
|
+
}
|
|
714
|
+
if (cell.horizontal_align) {
|
|
715
|
+
props.push(`horizontalAlign="${cell.horizontal_align}"`);
|
|
716
|
+
}
|
|
717
|
+
if (cell.vertical_align) {
|
|
718
|
+
props.push(`verticalAlign="${cell.vertical_align}"`);
|
|
719
|
+
}
|
|
720
|
+
if (cell.font_size != null) {
|
|
721
|
+
props.push(`fontSize={${cell.font_size}}`);
|
|
722
|
+
}
|
|
723
|
+
if (rowSpan !== 1) {
|
|
724
|
+
props.push(`rowSpan={${rowSpan}}`);
|
|
725
|
+
}
|
|
726
|
+
if (colSpan !== 1) {
|
|
727
|
+
props.push(`colSpan={${colSpan}}`);
|
|
728
|
+
}
|
|
729
|
+
if (averageColumnWidth > 0) {
|
|
730
|
+
props.push(`width={${averageColumnWidth}}`);
|
|
731
|
+
}
|
|
732
|
+
cellStrings.push(`<schematiccell ${props.join(" ")} />`);
|
|
733
|
+
}
|
|
734
|
+
rowStrings.push(
|
|
735
|
+
`<schematicrow height={${rowHeight}}>
|
|
736
|
+
${cellStrings.join("\n ")}
|
|
737
|
+
</schematicrow>`
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
const tableProps = [
|
|
741
|
+
`schX={${table.anchor_position.x}}`,
|
|
742
|
+
`schY={${table.anchor_position.y}}`
|
|
743
|
+
];
|
|
744
|
+
if (table.cell_padding != null) {
|
|
745
|
+
tableProps.push(`cellPadding={${table.cell_padding}}`);
|
|
746
|
+
}
|
|
747
|
+
if (table.border_width != null) {
|
|
748
|
+
tableProps.push(`borderWidth={${table.border_width}}`);
|
|
749
|
+
}
|
|
750
|
+
if (table.anchor) {
|
|
751
|
+
tableProps.push(`anchor="${table.anchor}"`);
|
|
752
|
+
}
|
|
753
|
+
elementStrings.push(
|
|
754
|
+
`<schematictable ${tableProps.join(" ")}>
|
|
755
|
+
${rowStrings.map((s) => s.split("\n").join("\n ")).join("\n ")}
|
|
756
|
+
</schematictable>`
|
|
757
|
+
);
|
|
758
|
+
}
|
|
680
759
|
if (elementStrings.length === 0) {
|
|
681
760
|
return null;
|
|
682
761
|
}
|
package/dist/cli/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
convertCircuitJsonToTscircuit
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-WC7XDXUV.js";
|
|
5
5
|
|
|
6
6
|
// cli/main.ts
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -16,7 +16,7 @@ var package_default = {
|
|
|
16
16
|
"./cli": "./dist/cli/main.js"
|
|
17
17
|
},
|
|
18
18
|
type: "module",
|
|
19
|
-
version: "0.0.
|
|
19
|
+
version: "0.0.34",
|
|
20
20
|
scripts: {
|
|
21
21
|
build: "tsup-node lib/index.ts cli/main.ts --format esm --dts",
|
|
22
22
|
test: "bun test",
|
package/dist/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
|
+
import { mmStr } from "@tscircuit/mm"
|
|
2
3
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
4
|
import { escapeJsxText } from "./helpers"
|
|
4
5
|
|
|
@@ -11,9 +12,15 @@ export const convertSilkscreenText: FootprintElementConverter = (
|
|
|
11
12
|
for (const silkscreenText of silkscreenTexts) {
|
|
12
13
|
const pcbX = silkscreenText.anchor_position?.x ?? 0
|
|
13
14
|
const pcbY = silkscreenText.anchor_position?.y ?? 0
|
|
15
|
+
const knockoutPadding = silkscreenText.knockout_padding
|
|
16
|
+
const hasUniformKnockoutPadding =
|
|
17
|
+
knockoutPadding &&
|
|
18
|
+
knockoutPadding.left === knockoutPadding.top &&
|
|
19
|
+
knockoutPadding.top === knockoutPadding.right &&
|
|
20
|
+
knockoutPadding.right === knockoutPadding.bottom
|
|
14
21
|
|
|
15
22
|
elementStrings.push(
|
|
16
|
-
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}} text="${escapeJsxText(silkscreenText.text)}" />`,
|
|
23
|
+
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== undefined ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== undefined ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== undefined ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? (hasUniformKnockoutPadding ? ` knockoutPadding="${mmStr(knockoutPadding.left)}"` : ` knockoutPaddingLeft="${mmStr(knockoutPadding.left)}" knockoutPaddingTop="${mmStr(knockoutPadding.top)}" knockoutPaddingRight="${mmStr(knockoutPadding.right)}" knockoutPaddingBottom="${mmStr(knockoutPadding.bottom)}"`) : ""}${silkscreenText.is_mirrored !== undefined ? ` mirrored={${silkscreenText.is_mirrored}}` : ""}${silkscreenText.layer !== undefined ? ` layer="${silkscreenText.layer}"` : ""} text="${escapeJsxText(silkscreenText.text)}" />`,
|
|
17
24
|
)
|
|
18
25
|
}
|
|
19
26
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { AnyCircuitElement } from "circuit-json"
|
|
2
2
|
import { su } from "@tscircuit/soup-util"
|
|
3
3
|
|
|
4
|
+
const escapeJsxText = (text: string) =>
|
|
5
|
+
text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
|
|
6
|
+
|
|
4
7
|
export const generateSymbolTsx = (
|
|
5
8
|
circuitJson: AnyCircuitElement[],
|
|
6
9
|
): string | null => {
|
|
@@ -11,6 +14,8 @@ export const generateSymbolTsx = (
|
|
|
11
14
|
const schematicCircles = su(circuitJson).schematic_circle.list()
|
|
12
15
|
const schematicBoxes = su(circuitJson).schematic_box.list()
|
|
13
16
|
const schematicRects = su(circuitJson).schematic_rect.list()
|
|
17
|
+
const schematicTables = su(circuitJson).schematic_table.list()
|
|
18
|
+
const schematicTableCells = su(circuitJson).schematic_table_cell.list()
|
|
14
19
|
const elementStrings: string[] = []
|
|
15
20
|
|
|
16
21
|
for (const arc of schematicArcs) {
|
|
@@ -126,7 +131,7 @@ export const generateSymbolTsx = (
|
|
|
126
131
|
const x = text.position?.x ?? 0
|
|
127
132
|
const y = text.position?.y ?? 0
|
|
128
133
|
const rawText = String(text.text ?? "")
|
|
129
|
-
const escapedText = rawText
|
|
134
|
+
const escapedText = escapeJsxText(rawText)
|
|
130
135
|
const anchorAlignment = text.anchor ?? "center"
|
|
131
136
|
const fontSize = text.font_size ?? 0.1
|
|
132
137
|
const color = text.color ?? "black"
|
|
@@ -151,6 +156,95 @@ export const generateSymbolTsx = (
|
|
|
151
156
|
)
|
|
152
157
|
}
|
|
153
158
|
|
|
159
|
+
for (const table of schematicTables) {
|
|
160
|
+
const tableCells = schematicTableCells
|
|
161
|
+
.filter((cell) => cell.schematic_table_id === table.schematic_table_id)
|
|
162
|
+
.sort((a, b) => {
|
|
163
|
+
if (a.start_row_index !== b.start_row_index) {
|
|
164
|
+
return a.start_row_index - b.start_row_index
|
|
165
|
+
}
|
|
166
|
+
return a.start_column_index - b.start_column_index
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const rowCount = table.row_heights.length
|
|
170
|
+
const rowStrings: string[] = []
|
|
171
|
+
|
|
172
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
173
|
+
const rowHeight = table.row_heights[rowIndex]
|
|
174
|
+
const rowCells = tableCells.filter(
|
|
175
|
+
(cell) => cell.start_row_index === rowIndex,
|
|
176
|
+
)
|
|
177
|
+
const cellStrings: string[] = []
|
|
178
|
+
|
|
179
|
+
for (const cell of rowCells) {
|
|
180
|
+
const rowSpan = cell.end_row_index - cell.start_row_index + 1
|
|
181
|
+
const colSpan = cell.end_column_index - cell.start_column_index + 1
|
|
182
|
+
const columnWidths = table.column_widths.slice(
|
|
183
|
+
cell.start_column_index,
|
|
184
|
+
cell.end_column_index + 1,
|
|
185
|
+
)
|
|
186
|
+
const averageColumnWidth =
|
|
187
|
+
columnWidths.length > 0
|
|
188
|
+
? columnWidths.reduce((sum, width) => sum + width, 0) /
|
|
189
|
+
columnWidths.length
|
|
190
|
+
: cell.width / Math.max(colSpan, 1)
|
|
191
|
+
|
|
192
|
+
const props: string[] = []
|
|
193
|
+
const text = cell.text ?? ""
|
|
194
|
+
|
|
195
|
+
if (text.length > 0) {
|
|
196
|
+
props.push(`text="${escapeJsxText(text)}"`)
|
|
197
|
+
}
|
|
198
|
+
if (cell.horizontal_align) {
|
|
199
|
+
props.push(`horizontalAlign="${cell.horizontal_align}"`)
|
|
200
|
+
}
|
|
201
|
+
if (cell.vertical_align) {
|
|
202
|
+
props.push(`verticalAlign="${cell.vertical_align}"`)
|
|
203
|
+
}
|
|
204
|
+
if (cell.font_size != null) {
|
|
205
|
+
props.push(`fontSize={${cell.font_size}}`)
|
|
206
|
+
}
|
|
207
|
+
if (rowSpan !== 1) {
|
|
208
|
+
props.push(`rowSpan={${rowSpan}}`)
|
|
209
|
+
}
|
|
210
|
+
if (colSpan !== 1) {
|
|
211
|
+
props.push(`colSpan={${colSpan}}`)
|
|
212
|
+
}
|
|
213
|
+
if (averageColumnWidth > 0) {
|
|
214
|
+
props.push(`width={${averageColumnWidth}}`)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
cellStrings.push(`<schematiccell ${props.join(" ")} />`)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
rowStrings.push(
|
|
221
|
+
`<schematicrow height={${rowHeight}}>
|
|
222
|
+
${cellStrings.join("\n ")}
|
|
223
|
+
</schematicrow>`,
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const tableProps = [
|
|
228
|
+
`schX={${table.anchor_position.x}}`,
|
|
229
|
+
`schY={${table.anchor_position.y}}`,
|
|
230
|
+
]
|
|
231
|
+
if (table.cell_padding != null) {
|
|
232
|
+
tableProps.push(`cellPadding={${table.cell_padding}}`)
|
|
233
|
+
}
|
|
234
|
+
if (table.border_width != null) {
|
|
235
|
+
tableProps.push(`borderWidth={${table.border_width}}`)
|
|
236
|
+
}
|
|
237
|
+
if (table.anchor) {
|
|
238
|
+
tableProps.push(`anchor="${table.anchor}"`)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
elementStrings.push(
|
|
242
|
+
`<schematictable ${tableProps.join(" ")}>
|
|
243
|
+
${rowStrings.map((s) => s.split("\n").join("\n ")).join("\n ")}
|
|
244
|
+
</schematictable>`,
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
154
248
|
if (elementStrings.length === 0) {
|
|
155
249
|
return null
|
|
156
250
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.1322"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600" data-type="pcb_background" data-pcb-layer="global"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="127.27272727272725" y="27.272727272727252" width="545.4545454545455" height="545.4545454545455" data-type="pcb_boundary" data-pcb-layer="global"/><path class="pcb-board" d="M 127.27272727272725 572.7272727272727 L 672.7272727272727 572.7272727272727 L 672.7272727272727 27.272727272727252 L 127.27272727272725 27.272727272727252 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="2.7272727272727275" data-type="pcb_board" data-pcb-layer="board"/><rect x="-1.7437906268656291" y="-0.6160611281665727" width="3.4875812537312583" height="1.2321222563331453" fill="#5da9e9" mask="url(#silkscreen-knockout-mask-pcb_silkscreen_text_1-1)" transform="matrix(27.272727272727273,3.339945815856418e-15,3.339945815856418e-15,-27.272727272727273,400,271.3636363636364)" class="pcb-silkscreen-text-knockout pcb-silkscreen-bottom" data-type="pcb_silkscreen_text" data-pcb-silkscreen-text-id="pcb_silkscreen_text_1" data-pcb-layer="bottom"/><rect x="-1.7437906268656291" y="-0.6160611281665727" width="3.4875812537312583" height="1.2321222563331453" fill="#5da9e9" mask="url(#silkscreen-knockout-mask-pcb_silkscreen_text_4-3)" transform="matrix(27.272727272727273,3.339945815856418e-15,3.339945815856418e-15,-27.272727272727273,400,271.3636363636364)" class="pcb-silkscreen-text-knockout pcb-silkscreen-bottom" data-type="pcb_silkscreen_text" data-pcb-silkscreen-text-id="pcb_silkscreen_text_4" data-pcb-layer="bottom"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="385" y="294.54545454545456" width="12.545454545454547" height="10.90909090909091" data-type="pcb_smtpad" data-pcb-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="402.4545454545455" y="294.54545454545456" width="12.545454545454547" height="10.90909090909091" data-type="pcb_smtpad" data-pcb-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="385" y="294.54545454545456" width="12.545454545454547" height="10.90909090909091" data-type="pcb_smtpad" data-pcb-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="402.4545454545455" y="294.54545454545456" width="12.545454545454547" height="10.90909090909091" data-type="pcb_smtpad" data-pcb-layer="top"/><rect x="-0.3864269372111764" y="-0.18227759906150554" width="0.7728538744223528" height="0.36455519812301107" fill="#f2eda1" mask="url(#silkscreen-knockout-mask-pcb_silkscreen_text_0-0)" transform="matrix(26.3434316260655,-7.058701230068747,7.058701230068747,26.3434316260655,400,190.9090909090909)" class="pcb-silkscreen-text-knockout pcb-silkscreen-top" data-type="pcb_silkscreen_text" data-pcb-silkscreen-text-id="pcb_silkscreen_text_0" data-pcb-layer="top"/><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="34.63636363636364" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,400,328.6363636363636)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_2" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">R_0201_0603Metric</text><rect x="-0.3864269372111764" y="-0.18227759906150554" width="0.7728538744223528" height="0.36455519812301107" fill="#f2eda1" mask="url(#silkscreen-knockout-mask-pcb_silkscreen_text_3-2)" transform="matrix(26.3434316260655,-7.058701230068747,7.058701230068747,26.3434316260655,400,190.9090909090909)" class="pcb-silkscreen-text-knockout pcb-silkscreen-top" data-type="pcb_silkscreen_text" data-pcb-silkscreen-text-id="pcb_silkscreen_text_3" data-pcb-layer="top"/><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="34.63636363636364" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,400,328.6363636363636)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_5" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">R_0201_0603Metric</text><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 391.8181818181818 295.90909090909093 L 408.1818181818182 295.90909090909093" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_0" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_0" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 391.8181818181818 304.09090909090907 L 391.8181818181818 295.90909090909093" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_0" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_1" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 408.1818181818182 295.90909090909093 L 408.1818181818182 304.09090909090907" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_0" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_2" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 408.1818181818182 304.09090909090907 L 391.8181818181818 304.09090909090907" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_0" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_3" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 391.8181818181818 295.90909090909093 L 408.1818181818182 295.90909090909093" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_1" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_4" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 391.8181818181818 304.09090909090907 L 391.8181818181818 295.90909090909093" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_1" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_5" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 408.1818181818182 295.90909090909093 L 408.1818181818182 304.09090909090907" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_1" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_6" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><path class="pcb-fabrication-note-path" stroke="rgba(255,255,255,0.5)" fill="none" d="M 408.1818181818182 304.09090909090907 L 391.8181818181818 304.09090909090907" stroke-width="2.7272727272727275" data-pcb-component-id="pcb_component_1" data-pcb-fabrication-note-path-id="pcb_fabrication_note_path_7" data-type="pcb_fabrication_note_path" data-pcb-layer="overlay"/><defs><mask id="silkscreen-knockout-mask-pcb_silkscreen_text_0-0"><rect x="-0.3864269372111764" y="-0.18227759906150554" width="0.7728538744223528" height="0.36455519812301107" fill="white"/><path d="M-0.21029812610767482 -0.02582012045164688L-0.223049754178108 -0.0395547480316605 M-0.223049754178108 -0.0395547480316605L-0.23561090358899242 -0.046323041724548424 M-0.23561090358899242 -0.046323041724548424L-0.254643286401408 -0.046323041724548424 M-0.254643286401408 -0.046323041724548424L-0.26739491447184116 -0.0395547480316605 M-0.26739491447184116 -0.0395547480316605L-0.280146182469194 -0.02582012045164688 M-0.280146182469194 -0.02582012045164688L-0.2864269372111764 -0.00511861887488687 M-0.2864269372111764 -0.00511861887488687L-0.2864269372111764 0.008616548814747431 M-0.2864269372111764 0.008616548814747431L-0.280146182469194 0.029119110014568565 M-0.280146182469194 0.029119110014568565L-0.26739491447184116 0.04285427770420285 M-0.26739491447184116 0.04285427770420285L-0.254643286401408 0.04982079162786878 M-0.254643286401408 0.04982079162786878L-0.23561090358899242 0.04982079162786878 M-0.23561090358899242 0.04982079162786878L-0.223049754178108 0.04285427770420285 M-0.223049754178108 0.04285427770420285L-0.21029812610767482 0.029119110014568565 M-0.1559178370842146 -0.08227759906150553L-0.1559178370842146 0.04493315963407931 M-0.1559178370842146 -0.015601786538595876L-0.13541239529975005 -0.03384939007220906 M-0.13541239529975005 -0.03384939007220906L-0.12167974812167878 -0.039815620978433795 M-0.12167974812167878 -0.039815620978433795L-0.10117448637375442 -0.039815620978433795 M-0.10117448637375442 -0.039815620978433795L-0.08753473805043471 -0.03384939007220906 M-0.08753473805043471 -0.03384939007220906L-0.08066796437004854 -0.015601786538595876 M-0.08066796437004854 -0.015601786538595876L-0.08066796437004854 0.04493315963407931 M0.004575268596514338 -0.08227759906150553L0.018978191813810524 -0.08227759906150553 M0.011768088451232062 -0.03981508086881314L0.011768088451232062 0.04493315963407931 M0.10149621167112076 -0.046323041724548424L0.10149621167112076 0.08227759906150553 M0.10149621167112076 -0.028027368434697518L0.11501371518363365 -0.04028353594645571 M0.11501371518363365 -0.04028353594645571L0.12832885762494356 -0.046323041724548424 M0.12832885762494356 -0.046323041724548424L0.14850393235811138 -0.046323041724548424 M0.14850393235811138 -0.046323041724548424L0.1620214358706243 -0.04028353594645571 M0.1620214358706243 -0.04028353594645571L0.17553839927351653 -0.028027368434697518 M0.17553839927351653 -0.028027368434697518L0.18219651060379213 -0.009554539189273868 M0.18219651060379213 -0.009554539189273868L0.18219651060379213 0.002701808359024553 M0.18219651060379213 0.002701808359024553L0.17553839927351653 0.020997121575794996 M0.17553839927351653 0.020997121575794996L0.1620214358706243 0.0332532890875532 M0.1620214358706243 0.0332532890875532L0.14850393235811138 0.03946977078467844 M0.14850393235811138 0.03946977078467844L0.12832885762494356 0.03946977078467844 M0.12832885762494356 0.03946977078467844L0.11501371518363365 0.0332532890875532 M0.11501371518363365 0.0332532890875532L0.10149621167112076 0.020997121575794996 M0.25740504692832455 -0.05199257241249685L0.2864269372111764 -0.07673931501137471 M0.2864269372111764 -0.07673931501137471L0.2864269372111764 0.04532005815900394" fill="none" stroke="black" stroke-width="0.02700548103243034" stroke-linecap="round" stroke-linejoin="round"/></mask></defs><defs><mask id="silkscreen-knockout-mask-pcb_silkscreen_text_1-1"><g transform="translate(-0.09999999999999987 -0.09999999999999987)"><rect x="-1.6437906268656293" y="-0.5160611281665728" width="3.4875812537312583" height="1.2321222563331453" fill="white"/><path d="M-1.5437906268656292 0.31161807120373153L-1.5437906268656292 -0.2879440223187698 M-1.5437906268656292 -0.2879440223187698L-1.3679935510911299 -0.30400414588144814 M-1.3679935510911299 -0.30400414588144814L-1.244605889931421 -0.2986346136811928 M-1.244605889931421 -0.2986346136811928L-1.170172338897903 -0.2821354890188513 M-1.170172338897903 -0.2821354890188513L-1.1388743042487905 -0.268684678242296 M-1.1388743042487905 -0.268684678242296L-1.113115000140429 -0.2511767656363536 M-1.113115000140429 -0.2511767656363536L-1.094085217055654 -0.22917183551573636 M-1.094085217055654 -0.22917183551573636L-1.0773053146066527 -0.1695006110440175 M-1.0773053146066527 -0.1695006110440175L-1.0788802310516945 -0.11658268682211739 M-1.0788802310516945 -0.11658268682211739L-1.096054319904768 -0.07826520750651558 M-1.096054319904768 -0.07826520750651558L-1.1268785992004942 -0.05201568550352989 M-1.1268785992004942 -0.05201568550352989L-1.1694022578022438 -0.03529614570573239 M-1.1694022578022438 -0.03529614570573239L-1.2508643993584942 -0.02254682210301409 M-1.2508643993584942 -0.02254682210301409L-1.5321378914264443 -0.01258881382565405 M-1.298551808395032 0.012726001669298798L-1.0570225492165894 0.3160611281665727 M-0.8417287274225179 -0.30400414588144814L-0.8417287274225179 0.3160611281665727 M-0.8417287274225179 -0.30400414588144814L-0.43757699838759284 -0.30400414588144814 M-0.8417287274225179 0.006026661971313713L-0.5588227000151952 0.006026661971313713 M-0.8417287274225179 0.3160611281665727L-0.43757699838759284 0.3160611281665727 M-0.17516921274341843 -0.30400414588144814L-0.17516921274341843 0.3160611281665727 M-0.1707078640680913 -0.29978699156780875L0.21737093720541528 -0.29978699156780875 M-0.1707078640680913 0.00391945669293034L0.15492120160707823 0.00391945669293034 M0.6818545873670522 -0.13233093668691007L0.6818545873670522 0.07184115808144428 M0.6818545873670522 -0.13233093668691007L0.8830369017295753 -0.06087253268923462 M0.6818545873670522 -0.13233093668691007L0.8089161389795675 -0.3160611281665727 M0.6818545873670522 -0.13233093668691007L0.5547930357545369 -0.3160611281665727 M0.6818545873670522 -0.13233093668691007L0.48067227300452914 -0.06087253268923462 M1.3426083125031059 -0.13233093668691007L1.3426083125031059 0.07184115808144428 M1.3426083125031059 -0.13233093668691007L1.5437906268656292 -0.06087253268923462 M1.3426083125031059 -0.13233093668691007L1.4696698641156214 -0.3160611281665727 M1.3426083125031059 -0.13233093668691007L1.2155467608905908 -0.3160611281665727 M1.3426083125031059 -0.13233093668691007L1.141425998140583 -0.06087253268923462" fill="none" stroke="black" stroke-width="0.13718784364474615" stroke-linecap="round" stroke-linejoin="round"/></g></mask></defs><defs><mask id="silkscreen-knockout-mask-pcb_silkscreen_text_3-2"><rect x="-0.3864269372111764" y="-0.18227759906150554" width="0.7728538744223528" height="0.36455519812301107" fill="white"/><path d="M-0.21029812610767482 -0.02582012045164688L-0.223049754178108 -0.0395547480316605 M-0.223049754178108 -0.0395547480316605L-0.23561090358899242 -0.046323041724548424 M-0.23561090358899242 -0.046323041724548424L-0.254643286401408 -0.046323041724548424 M-0.254643286401408 -0.046323041724548424L-0.26739491447184116 -0.0395547480316605 M-0.26739491447184116 -0.0395547480316605L-0.280146182469194 -0.02582012045164688 M-0.280146182469194 -0.02582012045164688L-0.2864269372111764 -0.00511861887488687 M-0.2864269372111764 -0.00511861887488687L-0.2864269372111764 0.008616548814747431 M-0.2864269372111764 0.008616548814747431L-0.280146182469194 0.029119110014568565 M-0.280146182469194 0.029119110014568565L-0.26739491447184116 0.04285427770420285 M-0.26739491447184116 0.04285427770420285L-0.254643286401408 0.04982079162786878 M-0.254643286401408 0.04982079162786878L-0.23561090358899242 0.04982079162786878 M-0.23561090358899242 0.04982079162786878L-0.223049754178108 0.04285427770420285 M-0.223049754178108 0.04285427770420285L-0.21029812610767482 0.029119110014568565 M-0.1559178370842146 -0.08227759906150553L-0.1559178370842146 0.04493315963407931 M-0.1559178370842146 -0.015601786538595876L-0.13541239529975005 -0.03384939007220906 M-0.13541239529975005 -0.03384939007220906L-0.12167974812167878 -0.039815620978433795 M-0.12167974812167878 -0.039815620978433795L-0.10117448637375442 -0.039815620978433795 M-0.10117448637375442 -0.039815620978433795L-0.08753473805043471 -0.03384939007220906 M-0.08753473805043471 -0.03384939007220906L-0.08066796437004854 -0.015601786538595876 M-0.08066796437004854 -0.015601786538595876L-0.08066796437004854 0.04493315963407931 M0.004575268596514338 -0.08227759906150553L0.018978191813810524 -0.08227759906150553 M0.011768088451232062 -0.03981508086881314L0.011768088451232062 0.04493315963407931 M0.10149621167112076 -0.046323041724548424L0.10149621167112076 0.08227759906150553 M0.10149621167112076 -0.028027368434697518L0.11501371518363365 -0.04028353594645571 M0.11501371518363365 -0.04028353594645571L0.12832885762494356 -0.046323041724548424 M0.12832885762494356 -0.046323041724548424L0.14850393235811138 -0.046323041724548424 M0.14850393235811138 -0.046323041724548424L0.1620214358706243 -0.04028353594645571 M0.1620214358706243 -0.04028353594645571L0.17553839927351653 -0.028027368434697518 M0.17553839927351653 -0.028027368434697518L0.18219651060379213 -0.009554539189273868 M0.18219651060379213 -0.009554539189273868L0.18219651060379213 0.002701808359024553 M0.18219651060379213 0.002701808359024553L0.17553839927351653 0.020997121575794996 M0.17553839927351653 0.020997121575794996L0.1620214358706243 0.0332532890875532 M0.1620214358706243 0.0332532890875532L0.14850393235811138 0.03946977078467844 M0.14850393235811138 0.03946977078467844L0.12832885762494356 0.03946977078467844 M0.12832885762494356 0.03946977078467844L0.11501371518363365 0.0332532890875532 M0.11501371518363365 0.0332532890875532L0.10149621167112076 0.020997121575794996 M0.25740504692832455 -0.05199257241249685L0.2864269372111764 -0.07673931501137471 M0.2864269372111764 -0.07673931501137471L0.2864269372111764 0.04532005815900394" fill="none" stroke="black" stroke-width="0.02700548103243034" stroke-linecap="round" stroke-linejoin="round"/></mask></defs><defs><mask id="silkscreen-knockout-mask-pcb_silkscreen_text_4-3"><g transform="translate(-0.09999999999999987 -0.09999999999999987)"><rect x="-1.6437906268656293" y="-0.5160611281665728" width="3.4875812537312583" height="1.2321222563331453" fill="white"/><path d="M-1.5437906268656292 0.31161807120373153L-1.5437906268656292 -0.2879440223187698 M-1.5437906268656292 -0.2879440223187698L-1.3679935510911299 -0.30400414588144814 M-1.3679935510911299 -0.30400414588144814L-1.244605889931421 -0.2986346136811928 M-1.244605889931421 -0.2986346136811928L-1.170172338897903 -0.2821354890188513 M-1.170172338897903 -0.2821354890188513L-1.1388743042487905 -0.268684678242296 M-1.1388743042487905 -0.268684678242296L-1.113115000140429 -0.2511767656363536 M-1.113115000140429 -0.2511767656363536L-1.094085217055654 -0.22917183551573636 M-1.094085217055654 -0.22917183551573636L-1.0773053146066527 -0.1695006110440175 M-1.0773053146066527 -0.1695006110440175L-1.0788802310516945 -0.11658268682211739 M-1.0788802310516945 -0.11658268682211739L-1.096054319904768 -0.07826520750651558 M-1.096054319904768 -0.07826520750651558L-1.1268785992004942 -0.05201568550352989 M-1.1268785992004942 -0.05201568550352989L-1.1694022578022438 -0.03529614570573239 M-1.1694022578022438 -0.03529614570573239L-1.2508643993584942 -0.02254682210301409 M-1.2508643993584942 -0.02254682210301409L-1.5321378914264443 -0.01258881382565405 M-1.298551808395032 0.012726001669298798L-1.0570225492165894 0.3160611281665727 M-0.8417287274225179 -0.30400414588144814L-0.8417287274225179 0.3160611281665727 M-0.8417287274225179 -0.30400414588144814L-0.43757699838759284 -0.30400414588144814 M-0.8417287274225179 0.006026661971313713L-0.5588227000151952 0.006026661971313713 M-0.8417287274225179 0.3160611281665727L-0.43757699838759284 0.3160611281665727 M-0.17516921274341843 -0.30400414588144814L-0.17516921274341843 0.3160611281665727 M-0.1707078640680913 -0.29978699156780875L0.21737093720541528 -0.29978699156780875 M-0.1707078640680913 0.00391945669293034L0.15492120160707823 0.00391945669293034 M0.6818545873670522 -0.13233093668691007L0.6818545873670522 0.07184115808144428 M0.6818545873670522 -0.13233093668691007L0.8830369017295753 -0.06087253268923462 M0.6818545873670522 -0.13233093668691007L0.8089161389795675 -0.3160611281665727 M0.6818545873670522 -0.13233093668691007L0.5547930357545369 -0.3160611281665727 M0.6818545873670522 -0.13233093668691007L0.48067227300452914 -0.06087253268923462 M1.3426083125031059 -0.13233093668691007L1.3426083125031059 0.07184115808144428 M1.3426083125031059 -0.13233093668691007L1.5437906268656292 -0.06087253268923462 M1.3426083125031059 -0.13233093668691007L1.4696698641156214 -0.3160611281665727 M1.3426083125031059 -0.13233093668691007L1.2155467608905908 -0.3160611281665727 M1.3426083125031059 -0.13233093668691007L1.141425998140583 -0.06087253268923462" fill="none" stroke="black" stroke-width="0.13718784364474615" stroke-linecap="round" stroke-linejoin="round"/></g></mask></defs></svg>
|
package/tests/__snapshots__/test7-support-schematic-elements-comprehensive-schematic-symbol.snap.svg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600" style="background-color: rgb(245, 241, 237)" data-real-to-screen-transform="matrix(
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600" style="background-color: rgb(245, 241, 237)" data-real-to-screen-transform="matrix(47.7510932281,0,0,-47.7510932281,588.062226693,265.7423474031)" data-software-used-string="@tscircuit/core@0.0.1306"><style>
|
|
2
2
|
.boundary { fill: rgb(245, 241, 237); }
|
|
3
3
|
.schematic-boundary { fill: none; stroke: #fff; }
|
|
4
4
|
.component { fill: none; stroke: rgb(132, 0, 0); }
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
.pin-number { fill: rgb(169, 0, 0); }
|
|
23
23
|
.port-label { fill: rgb(0, 100, 100); }
|
|
24
24
|
.component-name { fill: rgb(0, 100, 100); }
|
|
25
|
-
</style><rect class="boundary" x="0" y="0" width="1200" height="600"/><g data-circuit-json-type="schematic_component" data-schematic-component-id="schematic_component_0"><path d="M
|
|
25
|
+
</style><rect class="boundary" x="0" y="0" width="1200" height="600"/><g data-circuit-json-type="schematic_component" data-schematic-component-id="schematic_component_0"><path d="M 349.30676055249995 74.7379744907 A 47.7510932281 47.7510932281 0 0 0 253.80457409629997 74.7379744907" fill="none" stroke="black" stroke-width="2.387554661405" data-schematic-arc-id="schematic_arc_0" data-schematic-component-id="schematic_component_0"/><line x1="731.3155063772999" y1="74.7379744907" x2="874.5687860615999" y2="74.7379744907" stroke="black" stroke-width="2.387554661405" data-schematic-line-id="schematic_line_0" data-schematic-component-id="schematic_component_0"/><rect x="540.3111334649" y="50.86242787665" width="95.5021864562" height="47.7510932281" fill="purple" stroke="purple" stroke-width="2.387554661405" stroke-dasharray="7.1626639842149995" transform="rotate(30 588.062226693 74.7379744907)" data-schematic-rect-id="schematic_rect_0" data-schematic-component-id="schematic_component_0"/><path d="M 779.0665996053999 361.24453385929996 L 826.8176928334999 313.4934406312" stroke="blue" stroke-width="0.955021864562" fill="none" stroke-linecap="round" stroke-linejoin="round" data-schematic-component-id="schematic_component_0"/><circle cx="492.5600402368" cy="265.7423474031" r="23.87554661405" fill="green" stroke="green" stroke-width="2.387554661405" stroke-dasharray="7.1626639842149995" data-schematic-circle-id="schematic_circle_0" data-schematic-component-id="schematic_component_0"/></g><text x="588.062226693" y="265.7423474031" fill="red" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="9.55021864562px" transform="rotate(0, 588.062226693, 265.7423474031)">U1</text><rect class="schematic-box" x="540.3111334649" y="217.991254175" width="95.50218645619998" height="95.50218645619998" stroke-width="0.955021864562px" stroke="rgb(132, 0, 0)" fill="transparent"/><g data-schematic-table-id="schematic_table_0"><rect x="683.5644131491999" y="456.74672031549994" width="262.63101275455006" height="119.37773307025009" fill="none" stroke="rgb(102, 102, 102)" stroke-width="4.77510932281"/><line x1="802.9421462194499" y1="504.49781354359993" x2="802.9421462194499" y2="576.12445338575" stroke="rgb(102, 102, 102)" stroke-width="0.955021864562"/><line x1="683.5644131491999" y1="504.49781354359993" x2="802.9421462194499" y2="504.49781354359993" stroke="rgb(102, 102, 102)" stroke-width="0.955021864562"/><line x1="802.9421462194499" y1="504.49781354359993" x2="946.19542590375" y2="504.49781354359993" stroke="rgb(102, 102, 102)" stroke-width="0.955021864562"/><text x="814.879919526475" y="480.62226692954994" font-size="8.595196781057998px" text-anchor="middle" dominant-baseline="middle" fill="rgb(102, 102, 102)" font-family="sans-serif">Header</text><text x="693.11463179482" y="514.04803218922" font-size="8.595196781057998px" text-anchor="start" dominant-baseline="hanging" fill="rgb(102, 102, 102)" font-family="sans-serif">A2</text><text x="936.6452072581299" y="566.5742347401299" font-size="8.595196781057998px" text-anchor="end" dominant-baseline="ideographic" fill="rgb(102, 102, 102)" font-family="sans-serif">B2</text></g></svg>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { test, expect } from "bun:test"
|
|
2
|
+
import type { AnyCircuitElement, PcbSilkscreenText } from "circuit-json"
|
|
3
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
2
4
|
import { convertCircuitJsonToTscircuit } from "lib"
|
|
5
|
+
import { runTscircuitCode } from "tscircuit"
|
|
3
6
|
|
|
4
7
|
test("test4 support silkscreen", async () => {
|
|
5
8
|
const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
|
|
@@ -17,14 +20,67 @@ test("test4 support silkscreen", async () => {
|
|
|
17
20
|
<fabricationnotepath route={[{"x":-0.3,"y":-0.15},{"x":-0.3,"y":0.15}]} strokeWidth={0.1} />
|
|
18
21
|
<fabricationnotepath route={[{"x":0.3,"y":0.15},{"x":0.3,"y":-0.15}]} strokeWidth={0.1} />
|
|
19
22
|
<fabricationnotepath route={[{"x":0.3,"y":-0.15},{"x":-0.3,"y":-0.15}]} strokeWidth={0.1} />
|
|
20
|
-
<silkscreentext pcbX={0} pcbY={
|
|
21
|
-
<silkscreentext pcbX={0} pcbY={1.05} anchorAlignment="center" fontSize={1.27} text="REF**" />
|
|
22
|
-
<silkscreentext pcbX={0} pcbY={-1.05} anchorAlignment="center" fontSize={1.27} text="R_0201_0603Metric" />
|
|
23
|
+
<silkscreentext pcbX={0} pcbY={4} anchorAlignment="center" fontSize={0.25} font="tscircuit2024" pcbRotation="15deg" isKnockout={true} knockoutPadding="0.1mm" mirrored={true} layer="top" text="chip1" />
|
|
24
|
+
<silkscreentext pcbX={0} pcbY={1.05} anchorAlignment="center" fontSize={1.27} font="tscircuit2024" pcbRotation="180deg" isKnockout={true} knockoutPaddingLeft="0.1mm" knockoutPaddingTop="0.2mm" knockoutPaddingRight="0.3mm" knockoutPaddingBottom="0.4mm" layer="bottom" text="REF**" />
|
|
25
|
+
<silkscreentext pcbX={0} pcbY={-1.05} anchorAlignment="center" fontSize={1.27} font="tscircuit2024" layer="top" text="R_0201_0603Metric" />
|
|
23
26
|
</footprint>}
|
|
24
27
|
{...props}
|
|
25
28
|
/>
|
|
26
29
|
)"
|
|
27
30
|
`)
|
|
31
|
+
|
|
32
|
+
const renderedCircuitJson = (await runTscircuitCode(`
|
|
33
|
+
${tscircuit}
|
|
34
|
+
|
|
35
|
+
circuit.add(
|
|
36
|
+
<board width="20mm" height="20mm">
|
|
37
|
+
<Test4Component />
|
|
38
|
+
</board>,
|
|
39
|
+
)
|
|
40
|
+
`)) as AnyCircuitElement[]
|
|
41
|
+
|
|
42
|
+
const renderedSilkscreenTexts = renderedCircuitJson.filter(
|
|
43
|
+
(elm): elm is PcbSilkscreenText => elm.type === "pcb_silkscreen_text",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
expect(renderedSilkscreenTexts).toEqual(
|
|
47
|
+
expect.arrayContaining([
|
|
48
|
+
expect.objectContaining({
|
|
49
|
+
text: "chip1",
|
|
50
|
+
font: "tscircuit2024",
|
|
51
|
+
layer: "top",
|
|
52
|
+
ccw_rotation: 15,
|
|
53
|
+
is_knockout: true,
|
|
54
|
+
knockout_padding: {
|
|
55
|
+
left: 0.1,
|
|
56
|
+
top: 0.1,
|
|
57
|
+
right: 0.1,
|
|
58
|
+
bottom: 0.1,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
expect.objectContaining({
|
|
62
|
+
text: "REF**",
|
|
63
|
+
font: "tscircuit2024",
|
|
64
|
+
layer: "bottom",
|
|
65
|
+
ccw_rotation: 180,
|
|
66
|
+
is_knockout: true,
|
|
67
|
+
knockout_padding: {
|
|
68
|
+
left: 0.1,
|
|
69
|
+
top: 0.2,
|
|
70
|
+
right: 0.3,
|
|
71
|
+
bottom: 0.4,
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
expect.objectContaining({
|
|
75
|
+
text: "R_0201_0603Metric",
|
|
76
|
+
font: "tscircuit2024",
|
|
77
|
+
layer: "top",
|
|
78
|
+
}),
|
|
79
|
+
]),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(renderedCircuitJson)
|
|
83
|
+
await expect(pcbSvg).toMatchSvgSnapshot(import.meta.path, "pcb")
|
|
28
84
|
})
|
|
29
85
|
|
|
30
86
|
const circuitJson: any = [
|
|
@@ -161,25 +217,42 @@ const circuitJson: any = [
|
|
|
161
217
|
layer: "top",
|
|
162
218
|
font: "tscircuit2024",
|
|
163
219
|
font_size: 0.25,
|
|
220
|
+
ccw_rotation: 15,
|
|
164
221
|
pcb_component_id: "pcb_generic_component_0",
|
|
165
222
|
anchor_position: {
|
|
166
223
|
x: 0,
|
|
167
|
-
y:
|
|
224
|
+
y: 4,
|
|
168
225
|
},
|
|
169
226
|
anchor_alignment: "center",
|
|
170
|
-
|
|
227
|
+
is_knockout: true,
|
|
228
|
+
knockout_padding: {
|
|
229
|
+
left: 0.1,
|
|
230
|
+
top: 0.1,
|
|
231
|
+
right: 0.1,
|
|
232
|
+
bottom: 0.1,
|
|
233
|
+
},
|
|
234
|
+
is_mirrored: true,
|
|
235
|
+
text: "chip1",
|
|
171
236
|
},
|
|
172
237
|
{
|
|
173
238
|
type: "pcb_silkscreen_text",
|
|
174
|
-
layer: "
|
|
239
|
+
layer: "bottom",
|
|
175
240
|
font: "tscircuit2024",
|
|
176
241
|
font_size: 1.27,
|
|
242
|
+
ccw_rotation: 180,
|
|
177
243
|
pcb_component_id: "pcb_generic_component_0",
|
|
178
244
|
anchor_position: {
|
|
179
245
|
x: 0,
|
|
180
246
|
y: 1.05,
|
|
181
247
|
},
|
|
182
248
|
anchor_alignment: "center",
|
|
249
|
+
is_knockout: true,
|
|
250
|
+
knockout_padding: {
|
|
251
|
+
left: 0.1,
|
|
252
|
+
top: 0.2,
|
|
253
|
+
right: 0.3,
|
|
254
|
+
bottom: 0.4,
|
|
255
|
+
},
|
|
183
256
|
text: "REF**",
|
|
184
257
|
},
|
|
185
258
|
{
|
|
@@ -7,7 +7,7 @@ import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg"
|
|
|
7
7
|
const circuitJson: AnyCircuitElement[] = [
|
|
8
8
|
{
|
|
9
9
|
type: "schematic_arc",
|
|
10
|
-
center: { x:
|
|
10
|
+
center: { x: -6, y: 4 },
|
|
11
11
|
schematic_arc_id: "schematic_arc_id_1",
|
|
12
12
|
radius: 1,
|
|
13
13
|
schematic_component_id: "schematic_component_id_1",
|
|
@@ -20,12 +20,12 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
type: "schematic_line",
|
|
23
|
-
x1:
|
|
23
|
+
x1: 3,
|
|
24
24
|
schematic_line_id: "schematic_line_id_1",
|
|
25
25
|
schematic_component_id: "schematic_component_id_1",
|
|
26
|
-
y1:
|
|
27
|
-
x2:
|
|
28
|
-
y2:
|
|
26
|
+
y1: 4,
|
|
27
|
+
x2: 6,
|
|
28
|
+
y2: 4,
|
|
29
29
|
stroke_width: 0.05,
|
|
30
30
|
color: "black",
|
|
31
31
|
is_dashed: false,
|
|
@@ -33,8 +33,8 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
33
33
|
{
|
|
34
34
|
type: "schematic_box",
|
|
35
35
|
schematic_component_id: "schematic_component_id_1",
|
|
36
|
-
x:
|
|
37
|
-
y:
|
|
36
|
+
x: -6,
|
|
37
|
+
y: -1,
|
|
38
38
|
width: 2,
|
|
39
39
|
height: 2,
|
|
40
40
|
is_dashed: true,
|
|
@@ -43,7 +43,7 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
43
43
|
type: "schematic_rect",
|
|
44
44
|
schematic_rect_id: "schematic_rect_id_1",
|
|
45
45
|
schematic_component_id: "schematic_component_id_1",
|
|
46
|
-
center: { x:
|
|
46
|
+
center: { x: 0, y: 4 },
|
|
47
47
|
width: 2,
|
|
48
48
|
height: 1,
|
|
49
49
|
rotation: 30,
|
|
@@ -57,8 +57,8 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
57
57
|
type: "schematic_path",
|
|
58
58
|
schematic_path_id: "schematic_path_id_1",
|
|
59
59
|
points: [
|
|
60
|
-
{ x:
|
|
61
|
-
{ x:
|
|
60
|
+
{ x: 4, y: -2 },
|
|
61
|
+
{ x: 5, y: -1 },
|
|
62
62
|
],
|
|
63
63
|
fill_color: "blue",
|
|
64
64
|
is_dashed: false,
|
|
@@ -67,7 +67,7 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
67
67
|
type: "schematic_text",
|
|
68
68
|
schematic_text_id: "schematic_text_id_1",
|
|
69
69
|
text: "U1",
|
|
70
|
-
position: { x: 0, y:
|
|
70
|
+
position: { x: 0, y: 0 },
|
|
71
71
|
anchor: "center",
|
|
72
72
|
font_size: 0.2,
|
|
73
73
|
color: "red",
|
|
@@ -75,7 +75,7 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
type: "schematic_circle",
|
|
78
|
-
center: { x:
|
|
78
|
+
center: { x: -2, y: 0 },
|
|
79
79
|
schematic_circle_id: "schematic_circle_id_1",
|
|
80
80
|
radius: 0.5,
|
|
81
81
|
stroke_width: 0.05,
|
|
@@ -83,6 +83,62 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
83
83
|
is_filled: true,
|
|
84
84
|
is_dashed: true,
|
|
85
85
|
},
|
|
86
|
+
{
|
|
87
|
+
type: "schematic_table",
|
|
88
|
+
schematic_table_id: "schematic_table_1",
|
|
89
|
+
anchor_position: { x: 2, y: -4 },
|
|
90
|
+
column_widths: [2, 3],
|
|
91
|
+
row_heights: [1, 1.5],
|
|
92
|
+
cell_padding: 0.2,
|
|
93
|
+
border_width: 0.1,
|
|
94
|
+
anchor: "top_left",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: "schematic_table_cell",
|
|
98
|
+
schematic_table_cell_id: "schematic_table_cell_1",
|
|
99
|
+
schematic_table_id: "schematic_table_1",
|
|
100
|
+
start_row_index: 0,
|
|
101
|
+
end_row_index: 0,
|
|
102
|
+
start_column_index: 0,
|
|
103
|
+
end_column_index: 1,
|
|
104
|
+
text: "Header",
|
|
105
|
+
center: { x: 3.5, y: 0.5 },
|
|
106
|
+
width: 5,
|
|
107
|
+
height: 1,
|
|
108
|
+
horizontal_align: "center",
|
|
109
|
+
vertical_align: "middle",
|
|
110
|
+
font_size: 0.18,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "schematic_table_cell",
|
|
114
|
+
schematic_table_cell_id: "schematic_table_cell_2",
|
|
115
|
+
schematic_table_id: "schematic_table_1",
|
|
116
|
+
start_row_index: 1,
|
|
117
|
+
end_row_index: 1,
|
|
118
|
+
start_column_index: 0,
|
|
119
|
+
end_column_index: 0,
|
|
120
|
+
text: "A2",
|
|
121
|
+
center: { x: 2, y: -0.75 },
|
|
122
|
+
width: 2,
|
|
123
|
+
height: 1.5,
|
|
124
|
+
horizontal_align: "left",
|
|
125
|
+
vertical_align: "top",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "schematic_table_cell",
|
|
129
|
+
schematic_table_cell_id: "schematic_table_cell_3",
|
|
130
|
+
schematic_table_id: "schematic_table_1",
|
|
131
|
+
start_row_index: 1,
|
|
132
|
+
end_row_index: 1,
|
|
133
|
+
start_column_index: 1,
|
|
134
|
+
end_column_index: 1,
|
|
135
|
+
text: "B2",
|
|
136
|
+
center: { x: 4.5, y: -0.75 },
|
|
137
|
+
width: 3,
|
|
138
|
+
height: 1.5,
|
|
139
|
+
horizontal_align: "right",
|
|
140
|
+
vertical_align: "bottom",
|
|
141
|
+
},
|
|
86
142
|
]
|
|
87
143
|
|
|
88
144
|
test("test7 comprehensive schematic symbol support", async () => {
|
|
@@ -96,7 +152,7 @@ export const U1 = (props: ChipProps) => (
|
|
|
96
152
|
<chip
|
|
97
153
|
symbol={<symbol>
|
|
98
154
|
<schematicarc
|
|
99
|
-
center={{ x:
|
|
155
|
+
center={{ x: -6, y: 4 }}
|
|
100
156
|
radius={1}
|
|
101
157
|
startAngleDegrees={0}
|
|
102
158
|
endAngleDegrees={180}
|
|
@@ -105,12 +161,21 @@ export const U1 = (props: ChipProps) => (
|
|
|
105
161
|
isDashed={false}
|
|
106
162
|
direction="counterclockwise"
|
|
107
163
|
/>
|
|
108
|
-
<schematicline x1={
|
|
109
|
-
<schematicbox center={{ x:
|
|
110
|
-
<schematicrect schX={
|
|
111
|
-
<schematicpath points={[{"x":
|
|
112
|
-
<schematictext text="U1" x={0} y={
|
|
113
|
-
<schematiccircle center={{ x:
|
|
164
|
+
<schematicline x1={3} y1={4} x2={6} y2={4} strokeWidth={0.05} color="black" isDashed={false}/>
|
|
165
|
+
<schematicbox center={{ x: -6, y: -1 }} width={2} height={2} isDashed={true}/>
|
|
166
|
+
<schematicrect schX={0} schY={4} width={2} height={1} rotation={30} strokeWidth={0.05} color="purple" isFilled={true} fillColor="yellow" isDashed={true} />
|
|
167
|
+
<schematicpath points={[{"x":4,"y":-2},{"x":5,"y":-1}]} strokeColor="blue" fillColor="blue" isFilled={false}/>
|
|
168
|
+
<schematictext text="U1" x={0} y={0} anchorAlignment="center" fontSize={0.2} color="red" rotation={45} />
|
|
169
|
+
<schematiccircle center={{ x: -2, y: 0 }} radius={0.5} strokeWidth={0.05} color="green" isFilled={true} isDashed={true} />
|
|
170
|
+
<schematictable schX={2} schY={-4} cellPadding={0.2} borderWidth={0.1} anchor="top_left">
|
|
171
|
+
<schematicrow height={1}>
|
|
172
|
+
<schematiccell text="Header" horizontalAlign="center" verticalAlign="middle" fontSize={0.18} colSpan={2} width={2.5} />
|
|
173
|
+
</schematicrow>
|
|
174
|
+
<schematicrow height={1.5}>
|
|
175
|
+
<schematiccell text="A2" horizontalAlign="left" verticalAlign="top" width={2} />
|
|
176
|
+
<schematiccell text="B2" horizontalAlign="right" verticalAlign="bottom" width={3} />
|
|
177
|
+
</schematicrow>
|
|
178
|
+
</schematictable>
|
|
114
179
|
</symbol>}
|
|
115
180
|
{...props}
|
|
116
181
|
/>
|