circuit-to-svg 0.0.114 → 0.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -1
- package/dist/index.js +150 -60
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface Options$1 {
|
|
|
19
19
|
declare function convertCircuitJsonToAssemblySvg(soup: AnyCircuitElement[], options?: Options$1): string;
|
|
20
20
|
|
|
21
21
|
interface Options {
|
|
22
|
+
colorOverrides?: ColorOverrides;
|
|
22
23
|
width?: number;
|
|
23
24
|
height?: number;
|
|
24
25
|
grid?: boolean | {
|
|
@@ -31,10 +32,16 @@ interface Options {
|
|
|
31
32
|
label: string;
|
|
32
33
|
}>;
|
|
33
34
|
}
|
|
35
|
+
interface ColorOverrides {
|
|
36
|
+
schematic?: {
|
|
37
|
+
background?: string;
|
|
38
|
+
component_body?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
34
41
|
declare function convertCircuitJsonToSchematicSvg(circuitJson: AnyCircuitElement[], options?: Options): string;
|
|
35
42
|
/**
|
|
36
43
|
* @deprecated use `convertCircuitJsonToSchematicSvg` instead
|
|
37
44
|
*/
|
|
38
45
|
declare const circuitJsonToSchematicSvg: typeof convertCircuitJsonToSchematicSvg;
|
|
39
46
|
|
|
40
|
-
export { circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg };
|
|
47
|
+
export { type ColorOverrides, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg };
|
package/dist/index.js
CHANGED
|
@@ -1362,7 +1362,7 @@ function createSvgObjectsFromAssemblyComponent(component, transform, firstPin, n
|
|
|
1362
1362
|
type: "element",
|
|
1363
1363
|
value: "",
|
|
1364
1364
|
attributes: {
|
|
1365
|
-
transform: `translate(${x}, ${y})
|
|
1365
|
+
transform: `translate(${x}, ${y}) scale(1, -1)`
|
|
1366
1366
|
},
|
|
1367
1367
|
children: [
|
|
1368
1368
|
createComponentPath(
|
|
@@ -1384,33 +1384,43 @@ function createComponentPath(scaledWidth, scaledHeight, centerX, centerY, pinX,
|
|
|
1384
1384
|
const cornerSize = Math.min(w, h) * 0.3;
|
|
1385
1385
|
const isTop = pinY > centerY;
|
|
1386
1386
|
const isLeft = pinX < centerX;
|
|
1387
|
+
const strokeWidth = 0.8;
|
|
1387
1388
|
const path = getComponentPathData(w, h, cornerSize, isTop, isLeft, rotation);
|
|
1388
1389
|
return {
|
|
1389
1390
|
name: "path",
|
|
1390
1391
|
type: "element",
|
|
1391
1392
|
attributes: {
|
|
1392
1393
|
class: "assembly-component",
|
|
1393
|
-
d: path
|
|
1394
|
+
d: path,
|
|
1395
|
+
"stroke-width": strokeWidth.toFixed(2),
|
|
1396
|
+
transform: `rotate(${-rotation})`
|
|
1394
1397
|
},
|
|
1395
1398
|
value: "",
|
|
1396
1399
|
children: []
|
|
1397
1400
|
};
|
|
1398
1401
|
}
|
|
1399
1402
|
function createComponentLabel(scaledWidth, scaledHeight, name, transform) {
|
|
1400
|
-
const
|
|
1401
|
-
const
|
|
1402
|
-
const
|
|
1403
|
+
const size = Math.min(scaledWidth, scaledHeight);
|
|
1404
|
+
const minFontSize = 3;
|
|
1405
|
+
const maxFontSize = 58;
|
|
1406
|
+
const fontScale = 0.8;
|
|
1407
|
+
const fontSize = Math.min(
|
|
1408
|
+
maxFontSize,
|
|
1409
|
+
Math.max(minFontSize, size * fontScale)
|
|
1410
|
+
);
|
|
1411
|
+
const isTall = scaledHeight > scaledWidth;
|
|
1403
1412
|
return {
|
|
1404
1413
|
name: "text",
|
|
1405
1414
|
type: "element",
|
|
1406
1415
|
attributes: {
|
|
1407
1416
|
x: "0",
|
|
1408
|
-
y:
|
|
1417
|
+
y: "0",
|
|
1409
1418
|
class: "assembly-component-label",
|
|
1410
1419
|
"text-anchor": "middle",
|
|
1411
|
-
|
|
1412
|
-
"
|
|
1413
|
-
|
|
1420
|
+
dy: ".10em",
|
|
1421
|
+
style: "pointer-events: none",
|
|
1422
|
+
"font-size": `${fontSize.toFixed(1)}px`,
|
|
1423
|
+
transform: isTall ? "rotate(90) scale(1, -1)" : "scale(1, -1)"
|
|
1414
1424
|
},
|
|
1415
1425
|
children: [
|
|
1416
1426
|
{
|
|
@@ -1466,7 +1476,7 @@ function getComponentPathData(w, h, cornerSize, isTop, isLeft, rotation) {
|
|
|
1466
1476
|
];
|
|
1467
1477
|
}
|
|
1468
1478
|
const rotatedCorners = corners.map(([x, y]) => rotatePoint(x, y, rotation));
|
|
1469
|
-
const path = rotatedCorners.map(([x, y],
|
|
1479
|
+
const path = rotatedCorners.map(([x, y], i) => i === 0 ? `M${x},${y}` : `L${x},${y}`).join(" ");
|
|
1470
1480
|
return `${path} Z`;
|
|
1471
1481
|
}
|
|
1472
1482
|
|
|
@@ -1526,14 +1536,27 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
1526
1536
|
{
|
|
1527
1537
|
type: "text",
|
|
1528
1538
|
value: `
|
|
1529
|
-
.assembly-component {
|
|
1530
|
-
|
|
1539
|
+
.assembly-component {
|
|
1540
|
+
fill: #fff;
|
|
1541
|
+
stroke: #000;
|
|
1542
|
+
}
|
|
1543
|
+
.assembly-board {
|
|
1544
|
+
fill: #f2f2f2;
|
|
1545
|
+
stroke: rgb(0,0,0);
|
|
1546
|
+
stroke-opacity: 0.8;
|
|
1547
|
+
}
|
|
1531
1548
|
.assembly-component-label {
|
|
1532
1549
|
fill: #000;
|
|
1533
1550
|
font-family: Arial, serif;
|
|
1534
1551
|
font-weight: bold;
|
|
1552
|
+
dominant-baseline: middle;
|
|
1553
|
+
text-anchor: middle;
|
|
1554
|
+
}
|
|
1555
|
+
.assembly-boundary {
|
|
1556
|
+
fill: none;
|
|
1557
|
+
stroke: #fff;
|
|
1558
|
+
stroke-width: 0.2;
|
|
1535
1559
|
}
|
|
1536
|
-
.assembly-boundary { fill: none; stroke: #fff; stroke-width: 0.3; }
|
|
1537
1560
|
`,
|
|
1538
1561
|
name: "",
|
|
1539
1562
|
attributes: {},
|
|
@@ -1824,6 +1847,7 @@ var colorMap = {
|
|
|
1824
1847
|
hidden: "rgb(194, 194, 194)",
|
|
1825
1848
|
junction: "rgb(0, 150, 0)",
|
|
1826
1849
|
label_global: "rgb(132, 0, 0)",
|
|
1850
|
+
label_background: "rgba(255, 255, 255, 0.6)",
|
|
1827
1851
|
label_hier: "rgb(114, 86, 0)",
|
|
1828
1852
|
label_local: "rgb(15, 15, 15)",
|
|
1829
1853
|
net_name: "rgb(132, 132, 132)",
|
|
@@ -2197,7 +2221,8 @@ var ninePointAnchorToTextAnchor = {
|
|
|
2197
2221
|
var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
2198
2222
|
component: schComponent,
|
|
2199
2223
|
transform: realToScreenTransform,
|
|
2200
|
-
circuitJson
|
|
2224
|
+
circuitJson,
|
|
2225
|
+
colorMap: colorMap2
|
|
2201
2226
|
}) => {
|
|
2202
2227
|
const svgObjects = [];
|
|
2203
2228
|
const symbol = symbols[schComponent.symbol_name];
|
|
@@ -2285,7 +2310,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2285
2310
|
);
|
|
2286
2311
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
2287
2312
|
}).join(" ") + (closed ? " Z" : ""),
|
|
2288
|
-
stroke:
|
|
2313
|
+
stroke: colorMap2.schematic.component_outline,
|
|
2289
2314
|
fill: "none",
|
|
2290
2315
|
"stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`
|
|
2291
2316
|
},
|
|
@@ -2321,7 +2346,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2321
2346
|
attributes: {
|
|
2322
2347
|
x: screenTextPos.x.toString(),
|
|
2323
2348
|
y: (screenTextPos.y + verticalOffset).toString(),
|
|
2324
|
-
fill:
|
|
2349
|
+
fill: colorMap2.schematic.label_local,
|
|
2325
2350
|
"font-family": "sans-serif",
|
|
2326
2351
|
"text-anchor": ninePointAnchorToTextAnchor[text.anchor],
|
|
2327
2352
|
"dominant-baseline": dominantBaseline,
|
|
@@ -2376,7 +2401,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2376
2401
|
r: `${Math.abs(realToScreenTransform.a) * 0.02}px`,
|
|
2377
2402
|
"stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`,
|
|
2378
2403
|
fill: "none",
|
|
2379
|
-
stroke:
|
|
2404
|
+
stroke: colorMap2.schematic.component_outline
|
|
2380
2405
|
},
|
|
2381
2406
|
value: "",
|
|
2382
2407
|
children: []
|
|
@@ -2595,7 +2620,11 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
2595
2620
|
|
|
2596
2621
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
2597
2622
|
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
2598
|
-
var createSvgSchText = (
|
|
2623
|
+
var createSvgSchText = ({
|
|
2624
|
+
elm,
|
|
2625
|
+
transform,
|
|
2626
|
+
colorMap: colorMap2
|
|
2627
|
+
}) => {
|
|
2599
2628
|
const center = applyToPoint29(transform, elm.position);
|
|
2600
2629
|
const textAnchorMap = {
|
|
2601
2630
|
center: "middle",
|
|
@@ -2618,7 +2647,7 @@ var createSvgSchText = (elm, transform) => {
|
|
|
2618
2647
|
attributes: {
|
|
2619
2648
|
x: center.x.toString(),
|
|
2620
2649
|
y: center.y.toString(),
|
|
2621
|
-
fill: elm.color ??
|
|
2650
|
+
fill: elm.color ?? colorMap2.schematic.sheet_label,
|
|
2622
2651
|
"text-anchor": textAnchorMap[elm.anchor],
|
|
2623
2652
|
"dominant-baseline": dominantBaselineMap[elm.anchor],
|
|
2624
2653
|
"font-family": "sans-serif",
|
|
@@ -2641,7 +2670,8 @@ var createSvgSchText = (elm, transform) => {
|
|
|
2641
2670
|
var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
2642
2671
|
component: schComponent,
|
|
2643
2672
|
transform,
|
|
2644
|
-
circuitJson
|
|
2673
|
+
circuitJson,
|
|
2674
|
+
colorMap: colorMap2
|
|
2645
2675
|
}) => {
|
|
2646
2676
|
const svgObjects = [];
|
|
2647
2677
|
const componentScreenTopLeft = applyToPoint30(transform, {
|
|
@@ -2665,8 +2695,8 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
2665
2695
|
width: componentScreenWidth.toString(),
|
|
2666
2696
|
height: componentScreenHeight.toString(),
|
|
2667
2697
|
"stroke-width": `${getSchStrokeSize(transform)}px`,
|
|
2668
|
-
fill:
|
|
2669
|
-
stroke:
|
|
2698
|
+
fill: colorMap2.schematic.component_body,
|
|
2699
|
+
stroke: colorMap2.schematic.component_outline
|
|
2670
2700
|
},
|
|
2671
2701
|
children: []
|
|
2672
2702
|
});
|
|
@@ -2687,7 +2717,13 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
2687
2717
|
const schTexts = su7(circuitJson).schematic_text.list();
|
|
2688
2718
|
for (const schText of schTexts) {
|
|
2689
2719
|
if (schText.schematic_component_id === schComponent.schematic_component_id) {
|
|
2690
|
-
svgObjects.push(
|
|
2720
|
+
svgObjects.push(
|
|
2721
|
+
createSvgSchText({
|
|
2722
|
+
elm: schText,
|
|
2723
|
+
transform,
|
|
2724
|
+
colorMap: colorMap2
|
|
2725
|
+
})
|
|
2726
|
+
);
|
|
2691
2727
|
}
|
|
2692
2728
|
}
|
|
2693
2729
|
const schematicPorts = su7(circuitJson).schematic_port.list({
|
|
@@ -2726,7 +2762,11 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
2726
2762
|
|
|
2727
2763
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
2728
2764
|
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
2729
|
-
function createSvgObjectsFromSchVoltageProbe(
|
|
2765
|
+
function createSvgObjectsFromSchVoltageProbe({
|
|
2766
|
+
probe,
|
|
2767
|
+
transform,
|
|
2768
|
+
colorMap: colorMap2
|
|
2769
|
+
}) {
|
|
2730
2770
|
const [screenX, screenY] = applyToPoint31(transform, [
|
|
2731
2771
|
probe.position.x,
|
|
2732
2772
|
probe.position.y
|
|
@@ -2751,8 +2791,8 @@ function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
|
2751
2791
|
type: "element",
|
|
2752
2792
|
attributes: {
|
|
2753
2793
|
d: arrowPath,
|
|
2754
|
-
stroke:
|
|
2755
|
-
fill:
|
|
2794
|
+
stroke: colorMap2.schematic.reference,
|
|
2795
|
+
fill: colorMap2.schematic.reference,
|
|
2756
2796
|
"stroke-width": `${getSchStrokeSize(transform)}px`
|
|
2757
2797
|
},
|
|
2758
2798
|
value: "",
|
|
@@ -2765,7 +2805,7 @@ function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
|
2765
2805
|
attributes: {
|
|
2766
2806
|
x: (baseX + 8 - (baseX - baseX)).toString(),
|
|
2767
2807
|
y: (baseY - 10 + (baseY - baseY)).toString(),
|
|
2768
|
-
fill:
|
|
2808
|
+
fill: colorMap2.schematic.reference,
|
|
2769
2809
|
"text-anchor": "middle",
|
|
2770
2810
|
"dominant-baseline": "middle",
|
|
2771
2811
|
"font-family": "sans-serif",
|
|
@@ -2788,7 +2828,10 @@ function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
|
2788
2828
|
|
|
2789
2829
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
2790
2830
|
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
2791
|
-
function createSvgObjectsFromSchDebugObject(
|
|
2831
|
+
function createSvgObjectsFromSchDebugObject({
|
|
2832
|
+
debugObject,
|
|
2833
|
+
transform
|
|
2834
|
+
}) {
|
|
2792
2835
|
if (debugObject.shape === "rect") {
|
|
2793
2836
|
let [screenLeft, screenTop] = applyToPoint32(transform, [
|
|
2794
2837
|
debugObject.center.x - debugObject.size.width / 2,
|
|
@@ -2905,7 +2948,11 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2905
2948
|
|
|
2906
2949
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
2907
2950
|
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
2908
|
-
function createSchematicTrace(
|
|
2951
|
+
function createSchematicTrace({
|
|
2952
|
+
trace,
|
|
2953
|
+
transform,
|
|
2954
|
+
colorMap: colorMap2
|
|
2955
|
+
}) {
|
|
2909
2956
|
const edges = trace.edges;
|
|
2910
2957
|
if (edges.length === 0) return [];
|
|
2911
2958
|
const svgObjects = [];
|
|
@@ -2953,7 +3000,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2953
3000
|
attributes: {
|
|
2954
3001
|
class: "trace-crossing-outline",
|
|
2955
3002
|
d: `M ${screenFromX} ${screenFromY} Q ${controlX} ${controlY} ${screenToX} ${screenToY}`,
|
|
2956
|
-
stroke:
|
|
3003
|
+
stroke: colorMap2.schematic.background,
|
|
2957
3004
|
fill: "none",
|
|
2958
3005
|
"stroke-width": `${getSchStrokeSize(transform) * 1.5}px`,
|
|
2959
3006
|
"stroke-linecap": "round"
|
|
@@ -2966,7 +3013,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2966
3013
|
type: "element",
|
|
2967
3014
|
attributes: {
|
|
2968
3015
|
d: `M ${screenFromX} ${screenFromY} Q ${controlX} ${controlY} ${screenToX} ${screenToY}`,
|
|
2969
|
-
stroke:
|
|
3016
|
+
stroke: colorMap2.schematic.wire,
|
|
2970
3017
|
fill: "none",
|
|
2971
3018
|
"stroke-width": `${getSchStrokeSize(transform)}px`,
|
|
2972
3019
|
"stroke-linecap": "round"
|
|
@@ -2982,7 +3029,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2982
3029
|
attributes: {
|
|
2983
3030
|
d: path,
|
|
2984
3031
|
class: "trace-invisible-hover-outline",
|
|
2985
|
-
stroke:
|
|
3032
|
+
stroke: colorMap2.schematic.wire,
|
|
2986
3033
|
fill: "none",
|
|
2987
3034
|
"stroke-width": `${getSchStrokeSize(transform) * 8}px`,
|
|
2988
3035
|
"stroke-linecap": "round",
|
|
@@ -2997,7 +3044,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2997
3044
|
type: "element",
|
|
2998
3045
|
attributes: {
|
|
2999
3046
|
d: path,
|
|
3000
|
-
stroke:
|
|
3047
|
+
stroke: colorMap2.schematic.wire,
|
|
3001
3048
|
fill: "none",
|
|
3002
3049
|
"stroke-width": `${getSchStrokeSize(transform)}px`,
|
|
3003
3050
|
"stroke-linecap": "round",
|
|
@@ -3020,7 +3067,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
3020
3067
|
cx: screenX.toString(),
|
|
3021
3068
|
cy: screenY.toString(),
|
|
3022
3069
|
r: (Math.abs(transform.a) * 0.03).toString(),
|
|
3023
|
-
fill:
|
|
3070
|
+
fill: colorMap2.schematic.junction
|
|
3024
3071
|
},
|
|
3025
3072
|
value: "",
|
|
3026
3073
|
children: []
|
|
@@ -3885,7 +3932,11 @@ function getTextOffsets(pathRotation, transform) {
|
|
|
3885
3932
|
}
|
|
3886
3933
|
|
|
3887
3934
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
3888
|
-
var createSvgObjectsForSchNetLabelWithSymbol = (
|
|
3935
|
+
var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
3936
|
+
schNetLabel,
|
|
3937
|
+
realToScreenTransform,
|
|
3938
|
+
colorMap: colorMap2
|
|
3939
|
+
}) => {
|
|
3889
3940
|
if (!schNetLabel.text) return [];
|
|
3890
3941
|
const svgObjects = [];
|
|
3891
3942
|
const symbol = symbols3[schNetLabel.symbol_name];
|
|
@@ -4001,7 +4052,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
4001
4052
|
type: "element",
|
|
4002
4053
|
attributes: {
|
|
4003
4054
|
d: symbolPath + (path.closed ? " Z" : ""),
|
|
4004
|
-
stroke:
|
|
4055
|
+
stroke: colorMap2.schematic.component_outline,
|
|
4005
4056
|
fill: "none",
|
|
4006
4057
|
"stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`
|
|
4007
4058
|
},
|
|
@@ -4033,7 +4084,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
4033
4084
|
attributes: {
|
|
4034
4085
|
x: offsetScreenPos.x.toString(),
|
|
4035
4086
|
y: offsetScreenPos.y.toString(),
|
|
4036
|
-
fill:
|
|
4087
|
+
fill: colorMap2.schematic.label_local,
|
|
4037
4088
|
"font-family": "sans-serif",
|
|
4038
4089
|
"text-anchor": ninePointAnchorToTextAnchor2[text.anchor],
|
|
4039
4090
|
"dominant-baseline": ninePointAnchorToDominantBaseline[text.anchor],
|
|
@@ -4091,7 +4142,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
4091
4142
|
cy: screenCirclePos.y.toString(),
|
|
4092
4143
|
r: (circle.radius * symbolToScreenScale).toString(),
|
|
4093
4144
|
fill: "none",
|
|
4094
|
-
stroke:
|
|
4145
|
+
stroke: colorMap2.schematic.component_outline,
|
|
4095
4146
|
"stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`
|
|
4096
4147
|
},
|
|
4097
4148
|
value: "",
|
|
@@ -4102,13 +4153,18 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
4102
4153
|
};
|
|
4103
4154
|
|
|
4104
4155
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
4105
|
-
var createSvgObjectsForSchNetLabel = (
|
|
4156
|
+
var createSvgObjectsForSchNetLabel = ({
|
|
4157
|
+
schNetLabel,
|
|
4158
|
+
realToScreenTransform,
|
|
4159
|
+
colorMap: colorMap2
|
|
4160
|
+
}) => {
|
|
4106
4161
|
if (!schNetLabel.text) return [];
|
|
4107
4162
|
if (schNetLabel.symbol_name) {
|
|
4108
|
-
return createSvgObjectsForSchNetLabelWithSymbol(
|
|
4163
|
+
return createSvgObjectsForSchNetLabelWithSymbol({
|
|
4109
4164
|
schNetLabel,
|
|
4110
|
-
realToScreenTransform
|
|
4111
|
-
|
|
4165
|
+
realToScreenTransform,
|
|
4166
|
+
colorMap: colorMap2
|
|
4167
|
+
});
|
|
4112
4168
|
}
|
|
4113
4169
|
const svgObjects = [];
|
|
4114
4170
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
@@ -4186,8 +4242,8 @@ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
|
|
|
4186
4242
|
attributes: {
|
|
4187
4243
|
class: "net-label",
|
|
4188
4244
|
d: pathD,
|
|
4189
|
-
fill:
|
|
4190
|
-
stroke:
|
|
4245
|
+
fill: colorMap2.schematic.label_background,
|
|
4246
|
+
stroke: colorMap2.schematic.label_global,
|
|
4191
4247
|
"stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`
|
|
4192
4248
|
},
|
|
4193
4249
|
value: "",
|
|
@@ -4216,7 +4272,7 @@ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
|
|
|
4216
4272
|
class: "net-label-text",
|
|
4217
4273
|
x: screenTextPos.x.toString(),
|
|
4218
4274
|
y: screenTextPos.y.toString(),
|
|
4219
|
-
fill:
|
|
4275
|
+
fill: colorMap2.schematic.label_global,
|
|
4220
4276
|
"text-anchor": textAnchor,
|
|
4221
4277
|
"dominant-baseline": "central",
|
|
4222
4278
|
"font-family": "sans-serif",
|
|
@@ -4245,6 +4301,14 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4245
4301
|
const realHeight = realBounds.maxY - realBounds.minY;
|
|
4246
4302
|
const svgWidth = options?.width ?? 1200;
|
|
4247
4303
|
const svgHeight = options?.height ?? 600;
|
|
4304
|
+
const colorOverrides = options?.colorOverrides;
|
|
4305
|
+
const colorMap2 = {
|
|
4306
|
+
...colorMap,
|
|
4307
|
+
schematic: {
|
|
4308
|
+
...colorMap.schematic,
|
|
4309
|
+
...colorOverrides?.schematic ?? {}
|
|
4310
|
+
}
|
|
4311
|
+
};
|
|
4248
4312
|
const circuitAspectRatio = realWidth / realHeight;
|
|
4249
4313
|
const containerAspectRatio = svgWidth / svgHeight;
|
|
4250
4314
|
let screenPaddingPx;
|
|
@@ -4302,25 +4366,51 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4302
4366
|
for (const elm of circuitJson) {
|
|
4303
4367
|
if (elm.type === "schematic_debug_object") {
|
|
4304
4368
|
schDebugObjectSvgs.push(
|
|
4305
|
-
...createSvgObjectsFromSchDebugObject(
|
|
4369
|
+
...createSvgObjectsFromSchDebugObject({
|
|
4370
|
+
debugObject: elm,
|
|
4371
|
+
transform
|
|
4372
|
+
})
|
|
4306
4373
|
);
|
|
4307
4374
|
} else if (elm.type === "schematic_component") {
|
|
4308
4375
|
schComponentSvgs.push(
|
|
4309
4376
|
...createSvgObjectsFromSchematicComponent({
|
|
4310
4377
|
component: elm,
|
|
4311
4378
|
transform,
|
|
4312
|
-
circuitJson
|
|
4379
|
+
circuitJson,
|
|
4380
|
+
colorMap: colorMap2
|
|
4313
4381
|
})
|
|
4314
4382
|
);
|
|
4315
4383
|
} else if (elm.type === "schematic_trace") {
|
|
4316
|
-
schTraceSvgs.push(
|
|
4384
|
+
schTraceSvgs.push(
|
|
4385
|
+
...createSchematicTrace({
|
|
4386
|
+
trace: elm,
|
|
4387
|
+
transform,
|
|
4388
|
+
colorMap: colorMap2
|
|
4389
|
+
})
|
|
4390
|
+
);
|
|
4317
4391
|
} else if (elm.type === "schematic_net_label") {
|
|
4318
|
-
schNetLabel.push(
|
|
4392
|
+
schNetLabel.push(
|
|
4393
|
+
...createSvgObjectsForSchNetLabel({
|
|
4394
|
+
schNetLabel: elm,
|
|
4395
|
+
realToScreenTransform: transform,
|
|
4396
|
+
colorMap: colorMap2
|
|
4397
|
+
})
|
|
4398
|
+
);
|
|
4319
4399
|
} else if (elm.type === "schematic_text" && !elm.schematic_component_id) {
|
|
4320
|
-
schText.push(
|
|
4400
|
+
schText.push(
|
|
4401
|
+
createSvgSchText({
|
|
4402
|
+
elm,
|
|
4403
|
+
transform,
|
|
4404
|
+
colorMap: colorMap2
|
|
4405
|
+
})
|
|
4406
|
+
);
|
|
4321
4407
|
} else if (elm.type === "schematic_voltage_probe") {
|
|
4322
4408
|
voltageProbeSvgs.push(
|
|
4323
|
-
...createSvgObjectsFromSchVoltageProbe(
|
|
4409
|
+
...createSvgObjectsFromSchVoltageProbe({
|
|
4410
|
+
probe: elm,
|
|
4411
|
+
transform,
|
|
4412
|
+
colorMap: colorMap2
|
|
4413
|
+
})
|
|
4324
4414
|
);
|
|
4325
4415
|
}
|
|
4326
4416
|
}
|
|
@@ -4347,7 +4437,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4347
4437
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4348
4438
|
width: svgWidth.toString(),
|
|
4349
4439
|
height: svgHeight.toString(),
|
|
4350
|
-
style: `background-color: ${
|
|
4440
|
+
style: `background-color: ${colorMap2.schematic.background}`,
|
|
4351
4441
|
"data-real-to-screen-transform": toSVG(transform)
|
|
4352
4442
|
},
|
|
4353
4443
|
children: [
|
|
@@ -4361,21 +4451,21 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4361
4451
|
// DO NOT USE THESE CLASSES!!!!
|
|
4362
4452
|
// PUT STYLES IN THE SVG OBJECTS THEMSELVES
|
|
4363
4453
|
value: `
|
|
4364
|
-
.boundary { fill: ${
|
|
4454
|
+
.boundary { fill: ${colorMap2.schematic.background}; }
|
|
4365
4455
|
.schematic-boundary { fill: none; stroke: #fff; }
|
|
4366
|
-
.component { fill: none; stroke: ${
|
|
4367
|
-
.chip { fill: ${
|
|
4368
|
-
.component-pin { fill: none; stroke: ${
|
|
4456
|
+
.component { fill: none; stroke: ${colorMap2.schematic.component_outline}; }
|
|
4457
|
+
.chip { fill: ${colorMap2.schematic.component_body}; stroke: ${colorMap2.schematic.component_outline}; }
|
|
4458
|
+
.component-pin { fill: none; stroke: ${colorMap2.schematic.component_outline}; }
|
|
4369
4459
|
.trace:hover {
|
|
4370
4460
|
filter: invert(1);
|
|
4371
4461
|
}
|
|
4372
4462
|
.trace:hover .trace-crossing-outline {
|
|
4373
4463
|
opacity: 0;
|
|
4374
4464
|
}
|
|
4375
|
-
.text { font-family: sans-serif; fill: ${
|
|
4376
|
-
.pin-number { fill: ${
|
|
4377
|
-
.port-label { fill: ${
|
|
4378
|
-
.component-name { fill: ${
|
|
4465
|
+
.text { font-family: sans-serif; fill: ${colorMap2.schematic.wire}; }
|
|
4466
|
+
.pin-number { fill: ${colorMap2.schematic.pin_number}; }
|
|
4467
|
+
.port-label { fill: ${colorMap2.schematic.reference}; }
|
|
4468
|
+
.component-name { fill: ${colorMap2.schematic.reference}; }
|
|
4379
4469
|
`,
|
|
4380
4470
|
name: "",
|
|
4381
4471
|
attributes: {},
|