circuit-to-svg 0.0.167 → 0.0.169
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 +10 -2
- package/dist/index.js +73 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AnyCircuitElement } from 'circuit-json';
|
|
1
|
+
import { AnyCircuitElement, SchematicComponent } from 'circuit-json';
|
|
2
2
|
import { Matrix } from 'transformation-matrix';
|
|
3
|
+
import { INode } from 'svgson';
|
|
3
4
|
|
|
4
5
|
interface PcbColorMap {
|
|
5
6
|
copper: {
|
|
@@ -217,6 +218,7 @@ declare const colorMap: {
|
|
|
217
218
|
sheet_filename: string;
|
|
218
219
|
sheet_label: string;
|
|
219
220
|
sheet_name: string;
|
|
221
|
+
table: string;
|
|
220
222
|
value: string;
|
|
221
223
|
wire: string;
|
|
222
224
|
wire_crossing: string;
|
|
@@ -261,4 +263,10 @@ declare function getSoftwareUsedString(circuitJson: AnyCircuitElement[]): string
|
|
|
261
263
|
|
|
262
264
|
declare const CIRCUIT_TO_SVG_VERSION: string;
|
|
263
265
|
|
|
264
|
-
|
|
266
|
+
declare const createSvgObjectsForSchComponentPortHovers: ({ component, transform, circuitJson, }: {
|
|
267
|
+
component: SchematicComponent;
|
|
268
|
+
transform: Matrix;
|
|
269
|
+
circuitJson: AnyCircuitElement[];
|
|
270
|
+
}) => INode[];
|
|
271
|
+
|
|
272
|
+
export { type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask, createSvgObjectsForSchComponentPortHovers, getSoftwareUsedString };
|
package/dist/index.js
CHANGED
|
@@ -1446,7 +1446,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1446
1446
|
var package_default = {
|
|
1447
1447
|
name: "circuit-to-svg",
|
|
1448
1448
|
type: "module",
|
|
1449
|
-
version: "0.0.
|
|
1449
|
+
version: "0.0.168",
|
|
1450
1450
|
description: "Convert Circuit JSON to SVG",
|
|
1451
1451
|
main: "dist/index.js",
|
|
1452
1452
|
files: [
|
|
@@ -2902,6 +2902,7 @@ var colorMap = {
|
|
|
2902
2902
|
sheet_filename: "rgb(114, 86, 0)",
|
|
2903
2903
|
sheet_label: "rgb(0, 100, 100)",
|
|
2904
2904
|
sheet_name: "rgb(0, 100, 100)",
|
|
2905
|
+
table: "rgb(102, 102, 102)",
|
|
2905
2906
|
value: "rgb(0, 100, 100)",
|
|
2906
2907
|
wire: "rgb(0, 150, 0)",
|
|
2907
2908
|
wire_crossing: "rgb(30, 180, 30)",
|
|
@@ -5665,7 +5666,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5665
5666
|
width: (screenBottomRightX - screenTopLeftX).toString(),
|
|
5666
5667
|
height: (screenBottomRightY - screenTopLeftY).toString(),
|
|
5667
5668
|
fill: "none",
|
|
5668
|
-
stroke:
|
|
5669
|
+
stroke: colorMap2.schematic.table,
|
|
5669
5670
|
"stroke-width": borderStrokeWidth.toString()
|
|
5670
5671
|
},
|
|
5671
5672
|
children: [],
|
|
@@ -5694,7 +5695,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5694
5695
|
y1: start.y.toString(),
|
|
5695
5696
|
x2: end.x.toString(),
|
|
5696
5697
|
y2: end.y.toString(),
|
|
5697
|
-
stroke:
|
|
5698
|
+
stroke: colorMap2.schematic.table,
|
|
5698
5699
|
"stroke-width": gridStrokeWidth.toString()
|
|
5699
5700
|
},
|
|
5700
5701
|
children: [],
|
|
@@ -5727,7 +5728,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5727
5728
|
y1: start.y.toString(),
|
|
5728
5729
|
x2: end.x.toString(),
|
|
5729
5730
|
y2: end.y.toString(),
|
|
5730
|
-
stroke:
|
|
5731
|
+
stroke: colorMap2.schematic.table,
|
|
5731
5732
|
"stroke-width": gridStrokeWidth.toString()
|
|
5732
5733
|
},
|
|
5733
5734
|
children: [],
|
|
@@ -5785,7 +5786,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5785
5786
|
"font-size": `${fontSize}px`,
|
|
5786
5787
|
"text-anchor": textAnchorMap[horizontal_align],
|
|
5787
5788
|
"dominant-baseline": dominantBaselineMap[vertical_align],
|
|
5788
|
-
fill: colorMap2.schematic.
|
|
5789
|
+
fill: colorMap2.schematic.table,
|
|
5789
5790
|
"font-family": "sans-serif"
|
|
5790
5791
|
},
|
|
5791
5792
|
children: [
|
|
@@ -5814,6 +5815,58 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5814
5815
|
];
|
|
5815
5816
|
};
|
|
5816
5817
|
|
|
5818
|
+
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
5819
|
+
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
5820
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5821
|
+
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
5822
|
+
var createSvgObjectsForSchPortHover = ({
|
|
5823
|
+
schPort,
|
|
5824
|
+
transform
|
|
5825
|
+
}) => {
|
|
5826
|
+
const screenSchPortPos = applyToPoint43(transform, schPort.center);
|
|
5827
|
+
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
5828
|
+
return [
|
|
5829
|
+
{
|
|
5830
|
+
name: "g",
|
|
5831
|
+
type: "element",
|
|
5832
|
+
value: "",
|
|
5833
|
+
attributes: {
|
|
5834
|
+
class: "schematic-port-hover",
|
|
5835
|
+
"data-schematic-port-id": schPort.source_port_id
|
|
5836
|
+
},
|
|
5837
|
+
children: [
|
|
5838
|
+
{
|
|
5839
|
+
name: "circle",
|
|
5840
|
+
type: "element",
|
|
5841
|
+
value: "",
|
|
5842
|
+
attributes: {
|
|
5843
|
+
cx: screenSchPortPos.x.toString(),
|
|
5844
|
+
cy: screenSchPortPos.y.toString(),
|
|
5845
|
+
r: pinRadiusPx.toString(),
|
|
5846
|
+
fill: "red",
|
|
5847
|
+
opacity: "0"
|
|
5848
|
+
},
|
|
5849
|
+
children: []
|
|
5850
|
+
}
|
|
5851
|
+
]
|
|
5852
|
+
}
|
|
5853
|
+
];
|
|
5854
|
+
};
|
|
5855
|
+
var createSvgObjectsForSchComponentPortHovers = ({
|
|
5856
|
+
component,
|
|
5857
|
+
transform,
|
|
5858
|
+
circuitJson
|
|
5859
|
+
}) => {
|
|
5860
|
+
const schematicPorts = su8(circuitJson).schematic_port.list({
|
|
5861
|
+
schematic_component_id: component.schematic_component_id
|
|
5862
|
+
});
|
|
5863
|
+
const svgs = [];
|
|
5864
|
+
for (const schPort of schematicPorts) {
|
|
5865
|
+
svgs.push(...createSvgObjectsForSchPortHover({ schPort, transform }));
|
|
5866
|
+
}
|
|
5867
|
+
return svgs;
|
|
5868
|
+
};
|
|
5869
|
+
|
|
5817
5870
|
// lib/sch/convert-circuit-json-to-schematic-svg.ts
|
|
5818
5871
|
function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
5819
5872
|
const realBounds = getSchematicBoundsFromCircuitJson(circuitJson);
|
|
@@ -5885,6 +5938,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
5885
5938
|
const voltageProbeSvgs = [];
|
|
5886
5939
|
const schBoxSvgs = [];
|
|
5887
5940
|
const schTableSvgs = [];
|
|
5941
|
+
const schPortHoverSvgs = [];
|
|
5888
5942
|
for (const elm of circuitJson) {
|
|
5889
5943
|
if (elm.type === "schematic_debug_object") {
|
|
5890
5944
|
schDebugObjectSvgs.push(
|
|
@@ -5902,6 +5956,13 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
5902
5956
|
colorMap: colorMap2
|
|
5903
5957
|
})
|
|
5904
5958
|
);
|
|
5959
|
+
schPortHoverSvgs.push(
|
|
5960
|
+
...createSvgObjectsForSchComponentPortHovers({
|
|
5961
|
+
component: elm,
|
|
5962
|
+
transform,
|
|
5963
|
+
circuitJson
|
|
5964
|
+
})
|
|
5965
|
+
);
|
|
5905
5966
|
} else if (elm.type === "schematic_box") {
|
|
5906
5967
|
schBoxSvgs.push(
|
|
5907
5968
|
...createSvgObjectsFromSchematicBox({
|
|
@@ -5957,6 +6018,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
5957
6018
|
...schDebugObjectSvgs,
|
|
5958
6019
|
...schComponentSvgs,
|
|
5959
6020
|
...schTraceSvgs,
|
|
6021
|
+
...schPortHoverSvgs,
|
|
5960
6022
|
...schNetLabel,
|
|
5961
6023
|
...schText,
|
|
5962
6024
|
...schBoxSvgs,
|
|
@@ -6038,18 +6100,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
6038
6100
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
6039
6101
|
import { stringify as stringify4 } from "svgson";
|
|
6040
6102
|
import {
|
|
6041
|
-
applyToPoint as
|
|
6103
|
+
applyToPoint as applyToPoint46,
|
|
6042
6104
|
compose as compose11,
|
|
6043
6105
|
scale as scale8,
|
|
6044
6106
|
translate as translate11
|
|
6045
6107
|
} from "transformation-matrix";
|
|
6046
6108
|
|
|
6047
6109
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
6048
|
-
import { applyToPoint as
|
|
6110
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
6049
6111
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
6050
6112
|
const { transform, layer: layerFilter } = ctx;
|
|
6051
6113
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
6052
|
-
const [x, y] =
|
|
6114
|
+
const [x, y] = applyToPoint45(transform, [solderPaste.x, solderPaste.y]);
|
|
6053
6115
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
6054
6116
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
6055
6117
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -6252,8 +6314,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
6252
6314
|
}
|
|
6253
6315
|
}
|
|
6254
6316
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
6255
|
-
const [x1, y1] =
|
|
6256
|
-
const [x2, y2] =
|
|
6317
|
+
const [x1, y1] = applyToPoint46(transform, [minX, minY]);
|
|
6318
|
+
const [x2, y2] = applyToPoint46(transform, [maxX, maxY]);
|
|
6257
6319
|
const width = Math.abs(x2 - x1);
|
|
6258
6320
|
const height = Math.abs(y2 - y1);
|
|
6259
6321
|
const x = Math.min(x1, x2);
|
|
@@ -6283,6 +6345,7 @@ export {
|
|
|
6283
6345
|
convertCircuitJsonToPcbSvg,
|
|
6284
6346
|
convertCircuitJsonToSchematicSvg,
|
|
6285
6347
|
convertCircuitJsonToSolderPasteMask,
|
|
6348
|
+
createSvgObjectsForSchComponentPortHovers,
|
|
6286
6349
|
getSoftwareUsedString
|
|
6287
6350
|
};
|
|
6288
6351
|
//# sourceMappingURL=index.js.map
|