circuit-to-svg 0.0.293 → 0.0.295

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/README.md CHANGED
@@ -172,6 +172,8 @@ const schematicSimulationSvg = convertCircuitJsonToSchematicSimulationSvg({
172
172
  - `schematicOptions` – forward additional schematic rendering options (except `width`, `height`, and `includeVersion`).
173
173
  - `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
174
174
  the root `<svg>`.
175
+ - `graphAboveSchematic` – if `true`, place the simulation graph above the
176
+ schematic instead of below (defaults to `false`).
175
177
 
176
178
  ## convertCircuitJsonToSimulationGraphSvg
177
179
 
package/dist/index.d.ts CHANGED
@@ -341,9 +341,11 @@ interface ConvertSchematicSimulationParams {
341
341
  schematicHeightRatio?: number;
342
342
  schematicOptions?: Omit<Parameters<typeof convertCircuitJsonToSchematicSvg>[1], "width" | "height" | "includeVersion">;
343
343
  includeVersion?: boolean;
344
+ /** When true, place the simulation graph above the schematic instead of below (defaults to false). */
345
+ graphAboveSchematic?: boolean;
344
346
  showErrorsInTextOverlay?: boolean;
345
347
  }
346
- declare function convertCircuitJsonToSchematicSimulationSvg({ circuitJson, simulation_experiment_id, simulation_transient_voltage_graph_ids, width, height, schematicHeightRatio, schematicOptions, includeVersion, showErrorsInTextOverlay, }: ConvertSchematicSimulationParams): string;
348
+ declare function convertCircuitJsonToSchematicSimulationSvg({ circuitJson, simulation_experiment_id, simulation_transient_voltage_graph_ids, width, height, schematicHeightRatio, schematicOptions, includeVersion, graphAboveSchematic, showErrorsInTextOverlay, }: ConvertSchematicSimulationParams): string;
347
349
 
348
350
  interface Options {
349
351
  layer: "top" | "bottom";
package/dist/index.js CHANGED
@@ -5562,7 +5562,7 @@ function getSoftwareUsedString(circuitJson) {
5562
5562
  var package_default = {
5563
5563
  name: "circuit-to-svg",
5564
5564
  type: "module",
5565
- version: "0.0.292",
5565
+ version: "0.0.294",
5566
5566
  description: "Convert Circuit JSON to SVG",
5567
5567
  main: "dist/index.js",
5568
5568
  files: [
@@ -9564,6 +9564,30 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
9564
9564
  updateBounds(item.position, { width, height }, item.rotation ?? 0);
9565
9565
  } else if (item.type === "schematic_voltage_probe") {
9566
9566
  updateBounds(item.position, { width: 0.2, height: 0.4 }, 0);
9567
+ if (item.name) {
9568
+ const fontSize = getSchMmFontSize("net_label");
9569
+ const textWidth = estimateTextWidth(item.name) * fontSize;
9570
+ const textHeight = fontSize;
9571
+ const labelOffset = 0.3;
9572
+ const alignment = item.label_alignment ?? "top_right";
9573
+ let labelCenterX = item.position.x;
9574
+ let labelCenterY = item.position.y;
9575
+ if (alignment.includes("top")) {
9576
+ labelCenterY += labelOffset + textHeight / 2;
9577
+ } else if (alignment.includes("bottom")) {
9578
+ labelCenterY -= labelOffset + textHeight / 2;
9579
+ }
9580
+ if (alignment.includes("right")) {
9581
+ labelCenterX += labelOffset + textWidth / 2;
9582
+ } else if (alignment.includes("left")) {
9583
+ labelCenterX -= labelOffset + textWidth / 2;
9584
+ }
9585
+ updateBounds(
9586
+ { x: labelCenterX, y: labelCenterY },
9587
+ { width: textWidth, height: textHeight },
9588
+ 0
9589
+ );
9590
+ }
9567
9591
  } else if (item.type === "schematic_box") {
9568
9592
  updateBounds(
9569
9593
  {
@@ -12769,6 +12793,7 @@ function convertCircuitJsonToSchematicSimulationSvg({
12769
12793
  schematicHeightRatio = DEFAULT_SCHEMATIC_RATIO,
12770
12794
  schematicOptions,
12771
12795
  includeVersion,
12796
+ graphAboveSchematic = false,
12772
12797
  showErrorsInTextOverlay
12773
12798
  }) {
12774
12799
  const schematicElements = circuitJson.filter(
@@ -12799,18 +12824,33 @@ function convertCircuitJsonToSchematicSimulationSvg({
12799
12824
  const schematicNode = ensureElementNode(parseSync3(schematicSvg));
12800
12825
  const simulationNode = ensureElementNode(parseSync3(simulationSvg));
12801
12826
  const combinedChildren = [];
12802
- combinedChildren.push(
12803
- translateNestedSvg(schematicNode, 0, 0, width, schematicHeight)
12804
- );
12805
- combinedChildren.push(
12806
- translateNestedSvg(
12807
- simulationNode,
12808
- 0,
12809
- schematicHeight,
12810
- width,
12811
- simulationHeight
12812
- )
12813
- );
12827
+ if (graphAboveSchematic) {
12828
+ combinedChildren.push(
12829
+ translateNestedSvg(simulationNode, 0, 0, width, simulationHeight)
12830
+ );
12831
+ combinedChildren.push(
12832
+ translateNestedSvg(
12833
+ schematicNode,
12834
+ 0,
12835
+ simulationHeight,
12836
+ width,
12837
+ schematicHeight
12838
+ )
12839
+ );
12840
+ } else {
12841
+ combinedChildren.push(
12842
+ translateNestedSvg(schematicNode, 0, 0, width, schematicHeight)
12843
+ );
12844
+ combinedChildren.push(
12845
+ translateNestedSvg(
12846
+ simulationNode,
12847
+ 0,
12848
+ schematicHeight,
12849
+ width,
12850
+ simulationHeight
12851
+ )
12852
+ );
12853
+ }
12814
12854
  const softwareUsedString = getSoftwareUsedString(schematicElements);
12815
12855
  const svgObject = {
12816
12856
  name: "svg",