circuit-to-svg 0.0.294 → 0.0.296

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
@@ -2751,12 +2751,13 @@ var CHAR_WIDTH = 1;
2751
2751
  var CHAR_SPACING = 0.2;
2752
2752
  var LINE_HEIGHT = 1.4;
2753
2753
  var FONT_SCALE = 0.53;
2754
- function linesToPathData(lines, offsetX, offsetY, charScale) {
2754
+ var BASELINE_Y = 0.241;
2755
+ function linesToPathData(lines, offsetX, offsetY, charScale, baselineAdjust = 0) {
2755
2756
  return lines.map((line) => {
2756
2757
  const x1 = offsetX + line.x1 * charScale;
2757
- const y1 = offsetY + (1 - line.y1) * charScale;
2758
+ const y1 = offsetY + (1 - line.y1 + baselineAdjust) * charScale;
2758
2759
  const x2 = offsetX + line.x2 * charScale;
2759
- const y2 = offsetY + (1 - line.y2) * charScale;
2760
+ const y2 = offsetY + (1 - line.y2 + baselineAdjust) * charScale;
2760
2761
  return `M${x1} ${y1}L${x2} ${y2}`;
2761
2762
  }).join(" ");
2762
2763
  }
@@ -2771,7 +2772,9 @@ function textToAlphabetPath(text, fontSize) {
2771
2772
  }
2772
2773
  const lines = lineAlphabet[char];
2773
2774
  if (lines) {
2774
- paths.push(linesToPathData(lines, x, 0, fontSize));
2775
+ const isLowercase = char >= "a" && char <= "z";
2776
+ const baselineAdjust = isLowercase ? BASELINE_Y : 0;
2777
+ paths.push(linesToPathData(lines, x, 0, fontSize, baselineAdjust));
2775
2778
  }
2776
2779
  x += charAdvance;
2777
2780
  }
@@ -2804,7 +2807,9 @@ function textToCenteredAlphabetPaths(text, fontSize) {
2804
2807
  }
2805
2808
  const charLines = lineAlphabet[char];
2806
2809
  if (charLines) {
2807
- paths.push(linesToPathData(charLines, x, y, fontSize));
2810
+ const isLowercase = char >= "a" && char <= "z";
2811
+ const baselineAdjust = isLowercase ? BASELINE_Y : 0;
2812
+ paths.push(linesToPathData(charLines, x, y, fontSize, baselineAdjust));
2808
2813
  }
2809
2814
  x += charAdvance;
2810
2815
  }
@@ -2875,7 +2880,6 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
2875
2880
  id: maskId
2876
2881
  },
2877
2882
  children: [
2878
- // White background - area that will show copper
2879
2883
  {
2880
2884
  name: "rect",
2881
2885
  type: "element",
@@ -2889,7 +2893,6 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
2889
2893
  },
2890
2894
  children: []
2891
2895
  },
2892
- // Black text strokes - area that will be cut out
2893
2896
  {
2894
2897
  name: "path",
2895
2898
  type: "element",
@@ -5562,7 +5565,7 @@ function getSoftwareUsedString(circuitJson) {
5562
5565
  var package_default = {
5563
5566
  name: "circuit-to-svg",
5564
5567
  type: "module",
5565
- version: "0.0.293",
5568
+ version: "0.0.295",
5566
5569
  description: "Convert Circuit JSON to SVG",
5567
5570
  main: "dist/index.js",
5568
5571
  files: [
@@ -12793,6 +12796,7 @@ function convertCircuitJsonToSchematicSimulationSvg({
12793
12796
  schematicHeightRatio = DEFAULT_SCHEMATIC_RATIO,
12794
12797
  schematicOptions,
12795
12798
  includeVersion,
12799
+ graphAboveSchematic = false,
12796
12800
  showErrorsInTextOverlay
12797
12801
  }) {
12798
12802
  const schematicElements = circuitJson.filter(
@@ -12823,18 +12827,33 @@ function convertCircuitJsonToSchematicSimulationSvg({
12823
12827
  const schematicNode = ensureElementNode(parseSync3(schematicSvg));
12824
12828
  const simulationNode = ensureElementNode(parseSync3(simulationSvg));
12825
12829
  const combinedChildren = [];
12826
- combinedChildren.push(
12827
- translateNestedSvg(schematicNode, 0, 0, width, schematicHeight)
12828
- );
12829
- combinedChildren.push(
12830
- translateNestedSvg(
12831
- simulationNode,
12832
- 0,
12833
- schematicHeight,
12834
- width,
12835
- simulationHeight
12836
- )
12837
- );
12830
+ if (graphAboveSchematic) {
12831
+ combinedChildren.push(
12832
+ translateNestedSvg(simulationNode, 0, 0, width, simulationHeight)
12833
+ );
12834
+ combinedChildren.push(
12835
+ translateNestedSvg(
12836
+ schematicNode,
12837
+ 0,
12838
+ simulationHeight,
12839
+ width,
12840
+ schematicHeight
12841
+ )
12842
+ );
12843
+ } else {
12844
+ combinedChildren.push(
12845
+ translateNestedSvg(schematicNode, 0, 0, width, schematicHeight)
12846
+ );
12847
+ combinedChildren.push(
12848
+ translateNestedSvg(
12849
+ simulationNode,
12850
+ 0,
12851
+ schematicHeight,
12852
+ width,
12853
+ simulationHeight
12854
+ )
12855
+ );
12856
+ }
12838
12857
  const softwareUsedString = getSoftwareUsedString(schematicElements);
12839
12858
  const svgObject = {
12840
12859
  name: "svg",