circuit-json-to-tscircuit 0.0.32 → 0.0.34
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-Z6C3I2GJ.js → chunk-CQJKDULD.js} +42 -12
- package/dist/cli/main.js +3 -3
- package/dist/lib/index.js +1 -1
- package/lib/generate-footprint-tsx/convert-silkscreen-text.ts +8 -1
- package/lib/generate-symbol-tsx.ts +40 -7
- package/package.json +2 -2
- package/tests/__snapshots__/test18-support-schematic-dashes-schematic.snap.svg +25 -0
- 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/test18-support-schematic-dashes.test.tsx +77 -0
- package/tests/test4-support-silkscreen.test.tsx +79 -6
|
@@ -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
|
}
|
|
@@ -589,9 +592,24 @@ var generateSymbolTsx = (circuitJson) => {
|
|
|
589
592
|
const strokeWidth = line.stroke_width ?? 0.05;
|
|
590
593
|
const color = line.color ?? "black";
|
|
591
594
|
const isDashed = line.is_dashed ?? false;
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
+
const dashLength = line.dash_length;
|
|
596
|
+
const dashGap = line.dash_gap;
|
|
597
|
+
const attrs = [
|
|
598
|
+
`x1={${x1}}`,
|
|
599
|
+
`y1={${y1}}`,
|
|
600
|
+
`x2={${x2}}`,
|
|
601
|
+
`y2={${y2}}`,
|
|
602
|
+
`strokeWidth={${strokeWidth}}`,
|
|
603
|
+
`color="${color}"`,
|
|
604
|
+
`isDashed={${isDashed}}`
|
|
605
|
+
];
|
|
606
|
+
if (dashLength != null) {
|
|
607
|
+
attrs.push(`dashLength={${dashLength}}`);
|
|
608
|
+
}
|
|
609
|
+
if (dashGap != null) {
|
|
610
|
+
attrs.push(`dashGap={${dashGap}}`);
|
|
611
|
+
}
|
|
612
|
+
elementStrings.push(`<schematicline ${attrs.join(" ")}/>`);
|
|
595
613
|
}
|
|
596
614
|
for (const box of schematicBoxes) {
|
|
597
615
|
const x = box.x ?? 0;
|
|
@@ -621,9 +639,21 @@ var generateSymbolTsx = (circuitJson) => {
|
|
|
621
639
|
const points = path.points ?? [];
|
|
622
640
|
const fillColor = path.fill_color ?? "red";
|
|
623
641
|
const isFilled = path.is_filled ?? false;
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
642
|
+
const dashLength = path.dash_length;
|
|
643
|
+
const dashGap = path.dash_gap;
|
|
644
|
+
const attrs = [
|
|
645
|
+
`points={${JSON.stringify(points)}}`,
|
|
646
|
+
`strokeColor="${fillColor}"`,
|
|
647
|
+
`fillColor="${fillColor}"`,
|
|
648
|
+
`isFilled={${isFilled}}`
|
|
649
|
+
];
|
|
650
|
+
if (dashLength != null) {
|
|
651
|
+
attrs.push(`dashLength={${dashLength}}`);
|
|
652
|
+
}
|
|
653
|
+
if (dashGap != null) {
|
|
654
|
+
attrs.push(`dashGap={${dashGap}}`);
|
|
655
|
+
}
|
|
656
|
+
elementStrings.push(`<schematicpath ${attrs.join(" ")}/>`);
|
|
627
657
|
}
|
|
628
658
|
for (const text of schematicTexts) {
|
|
629
659
|
const x = text.position?.x ?? 0;
|
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-CQJKDULD.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.33",
|
|
20
20
|
scripts: {
|
|
21
21
|
build: "tsup-node lib/index.ts cli/main.ts --format esm --dts",
|
|
22
22
|
test: "bun test",
|
|
@@ -34,7 +34,7 @@ var package_default = {
|
|
|
34
34
|
"circuit-json": "^0.0.433",
|
|
35
35
|
"circuit-to-svg": "^0.0.353",
|
|
36
36
|
commander: "^13.1.0",
|
|
37
|
-
tscircuit: "^0.0.
|
|
37
|
+
tscircuit: "^0.0.1873",
|
|
38
38
|
tsup: "^8.3.5"
|
|
39
39
|
},
|
|
40
40
|
peerDependencies: {
|
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
|
|
|
@@ -45,10 +45,28 @@ export const generateSymbolTsx = (
|
|
|
45
45
|
const strokeWidth = line.stroke_width ?? 0.05
|
|
46
46
|
const color = line.color ?? "black"
|
|
47
47
|
const isDashed = line.is_dashed ?? false
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const dashLength = line.dash_length
|
|
49
|
+
const dashGap = line.dash_gap
|
|
50
|
+
|
|
51
|
+
const attrs = [
|
|
52
|
+
`x1={${x1}}`,
|
|
53
|
+
`y1={${y1}}`,
|
|
54
|
+
`x2={${x2}}`,
|
|
55
|
+
`y2={${y2}}`,
|
|
56
|
+
`strokeWidth={${strokeWidth}}`,
|
|
57
|
+
`color="${color}"`,
|
|
58
|
+
`isDashed={${isDashed}}`,
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
if (dashLength != null) {
|
|
62
|
+
attrs.push(`dashLength={${dashLength}}`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (dashGap != null) {
|
|
66
|
+
attrs.push(`dashGap={${dashGap}}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
elementStrings.push(`<schematicline ${attrs.join(" ")}/>`)
|
|
52
70
|
}
|
|
53
71
|
|
|
54
72
|
for (const box of schematicBoxes) {
|
|
@@ -83,10 +101,25 @@ export const generateSymbolTsx = (
|
|
|
83
101
|
const points = path.points ?? []
|
|
84
102
|
const fillColor = path.fill_color ?? "red"
|
|
85
103
|
const isFilled = path.is_filled ?? false
|
|
104
|
+
const dashLength = path.dash_length
|
|
105
|
+
const dashGap = path.dash_gap
|
|
86
106
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
107
|
+
const attrs = [
|
|
108
|
+
`points={${JSON.stringify(points)}}`,
|
|
109
|
+
`strokeColor="${fillColor}"`,
|
|
110
|
+
`fillColor="${fillColor}"`,
|
|
111
|
+
`isFilled={${isFilled}}`,
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
if (dashLength != null) {
|
|
115
|
+
attrs.push(`dashLength={${dashLength}}`)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (dashGap != null) {
|
|
119
|
+
attrs.push(`dashGap={${dashGap}}`)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
elementStrings.push(`<schematicpath ${attrs.join(" ")}/>`)
|
|
90
123
|
}
|
|
91
124
|
|
|
92
125
|
for (const text of schematicTexts) {
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"./cli": "./dist/cli/main.js"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.34",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsup-node lib/index.ts cli/main.ts --format esm --dts",
|
|
12
12
|
"test": "bun test",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"circuit-json": "^0.0.433",
|
|
25
25
|
"circuit-to-svg": "^0.0.353",
|
|
26
26
|
"commander": "^13.1.0",
|
|
27
|
-
"tscircuit": "^0.0.
|
|
27
|
+
"tscircuit": "^0.0.1873",
|
|
28
28
|
"tsup": "^8.3.5"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -0,0 +1,25 @@
|
|
|
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(198.6754966887,0,0,-198.6754966887,401.3245033113,498.6754966887)" data-software-used-string="@tscircuit/core@0.0.1322"><style>
|
|
2
|
+
.boundary { fill: rgb(245, 241, 237); }
|
|
3
|
+
.schematic-boundary { fill: none; stroke: #fff; }
|
|
4
|
+
.component { fill: none; stroke: rgb(132, 0, 0); }
|
|
5
|
+
.chip { fill: rgb(255, 255, 194); stroke: rgb(132, 0, 0); }
|
|
6
|
+
.component-pin { fill: none; stroke: rgb(132, 0, 0); }
|
|
7
|
+
/* Basic per-trace hover fallback */
|
|
8
|
+
.trace:hover {
|
|
9
|
+
filter: invert(1);
|
|
10
|
+
}
|
|
11
|
+
.trace:hover .trace-crossing-outline {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
}
|
|
14
|
+
.trace:hover .trace-junction {
|
|
15
|
+
filter: invert(1);
|
|
16
|
+
}
|
|
17
|
+
/* Net-hover highlighting: when a trace or its overlays are hovered,
|
|
18
|
+
invert color for all traces (base + overlays) sharing the same
|
|
19
|
+
subcircuit connectivity key. Also hide crossing outline during hover. */
|
|
20
|
+
|
|
21
|
+
.text { font-family: sans-serif; fill: rgb(0, 150, 0); }
|
|
22
|
+
.pin-number { fill: rgb(169, 0, 0); }
|
|
23
|
+
.port-label { fill: rgb(0, 100, 100); }
|
|
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"><line x1="401.3245033113" y1="498.6754966887" x2="798.6754966887" y2="498.6754966887" stroke="black" stroke-width="9.933774834435" stroke-dasharray="39.73509933774 19.86754966887" data-schematic-line-id="schematic_line_0" data-schematic-component-id="schematic_component_0"/><path d="M 401.3245033113 300 L 600 101.32450331129996" stroke="blue" stroke-width="3.9735099337740003" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="29.801324503305 9.933774834435" data-schematic-component-id="schematic_component_0"/></g></svg>
|
|
@@ -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(70.0512524814,0,0,-70.0512524814,599.6497437376,319.7949900745)" data-software-used-string="@tscircuit/core@0.0.
|
|
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(70.0512524814,0,0,-70.0512524814,599.6497437376,319.7949900745)" data-software-used-string="@tscircuit/core@0.0.1322"><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"/><
|
|
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 669.700996219 319.7949900745 A 70.0512524814 70.0512524814 0 0 0 529.5984912562001 319.7949900745" fill="none" stroke="black" stroke-width="3.5025626240700003" data-schematic-arc-id="schematic_arc_0" data-schematic-component-id="schematic_component_0"/><line x1="739.7522487004001" y1="319.7949900745" x2="879.8547536632" y2="319.7949900745" stroke="black" stroke-width="3.5025626240700003" data-schematic-line-id="schematic_line_0" data-schematic-component-id="schematic_component_0"/><rect x="319.44473381200004" y="74.6156063896" width="140.1025049628" height="70.0512524814" fill="purple" stroke="purple" stroke-width="3.5025626240700003" stroke-dasharray="10.507687872210001" transform="rotate(30 389.49598629340005 109.64123263030001)" data-schematic-rect-id="schematic_rect_0" data-schematic-component-id="schematic_component_0"/><path d="M 809.8035011818 109.64123263030001 L 879.8547536632 39.5899801489" stroke="blue" stroke-width="1.401025049628" fill="none" stroke-linecap="round" stroke-linejoin="round" data-schematic-component-id="schematic_component_0"/><circle cx="809.8035011818" cy="529.9487475187" r="35.0256262407" fill="green" stroke="green" stroke-width="3.5025626240700003" stroke-dasharray="10.507687872210001" data-schematic-circle-id="schematic_circle_0" data-schematic-component-id="schematic_component_0"/></g><text x="599.6497437376" y="319.7949900745" fill="red" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="14.010250496280001px" transform="rotate(0, 599.6497437376, 319.7949900745)">U1</text><rect class="schematic-box" x="529.5984912562001" y="249.74373759309998" width="140.1025049627999" height="140.10250496280003" stroke-width="1.401025049628px" stroke="rgb(132, 0, 0)" fill="transparent"/></svg>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { convertCircuitJsonToTscircuit } from "lib/index"
|
|
3
|
+
import type { AnyCircuitElement } from "circuit-json"
|
|
4
|
+
import { runTscircuitCode } from "tscircuit"
|
|
5
|
+
import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg"
|
|
6
|
+
|
|
7
|
+
const circuitJson: AnyCircuitElement[] = [
|
|
8
|
+
{
|
|
9
|
+
type: "schematic_line",
|
|
10
|
+
schematic_line_id: "schematic_line_id_1",
|
|
11
|
+
schematic_component_id: "schematic_component_id_1",
|
|
12
|
+
x1: 0,
|
|
13
|
+
y1: 0,
|
|
14
|
+
x2: 2,
|
|
15
|
+
y2: 0,
|
|
16
|
+
stroke_width: 0.05,
|
|
17
|
+
color: "black",
|
|
18
|
+
is_dashed: true,
|
|
19
|
+
dash_length: 0.2,
|
|
20
|
+
dash_gap: 0.1,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "schematic_path",
|
|
24
|
+
schematic_path_id: "schematic_path_id_1",
|
|
25
|
+
schematic_component_id: "schematic_component_id_1",
|
|
26
|
+
points: [
|
|
27
|
+
{ x: 0, y: 1 },
|
|
28
|
+
{ x: 1, y: 2 },
|
|
29
|
+
],
|
|
30
|
+
fill_color: "blue",
|
|
31
|
+
is_dashed: true,
|
|
32
|
+
dash_length: 0.15,
|
|
33
|
+
dash_gap: 0.05,
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
test("test18 support schematic dashLength and dashGap", async () => {
|
|
38
|
+
const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
|
|
39
|
+
componentName: "DashedSymbol",
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
expect(tscircuit).toMatchInlineSnapshot(`
|
|
43
|
+
"import { type ChipProps } from "tscircuit"
|
|
44
|
+
export const DashedSymbol = (props: ChipProps) => (
|
|
45
|
+
<chip
|
|
46
|
+
symbol={<symbol>
|
|
47
|
+
<schematicline x1={0} y1={0} x2={2} y2={0} strokeWidth={0.05} color="black" isDashed={true} dashLength={0.2} dashGap={0.1}/>
|
|
48
|
+
<schematicpath points={[{"x":0,"y":1},{"x":1,"y":2}]} strokeColor="blue" fillColor="blue" isFilled={false} dashLength={0.15} dashGap={0.05}/>
|
|
49
|
+
</symbol>}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)"
|
|
53
|
+
`)
|
|
54
|
+
|
|
55
|
+
const result = await runTscircuitCode(tscircuit)
|
|
56
|
+
|
|
57
|
+
expect(result).toEqual(
|
|
58
|
+
expect.arrayContaining([
|
|
59
|
+
expect.objectContaining({
|
|
60
|
+
type: "schematic_line",
|
|
61
|
+
is_dashed: true,
|
|
62
|
+
dash_length: 0.2,
|
|
63
|
+
dash_gap: 0.1,
|
|
64
|
+
}),
|
|
65
|
+
expect.objectContaining({
|
|
66
|
+
type: "schematic_path",
|
|
67
|
+
dash_length: 0.15,
|
|
68
|
+
dash_gap: 0.05,
|
|
69
|
+
}),
|
|
70
|
+
]),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const schematicSvg = convertCircuitJsonToSchematicSvg(
|
|
74
|
+
result as AnyCircuitElement[],
|
|
75
|
+
)
|
|
76
|
+
await expect(schematicSvg).toMatchSvgSnapshot(import.meta.path, "schematic")
|
|
77
|
+
})
|
|
@@ -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
|
{
|