circuit-to-svg 0.0.223 → 0.0.225

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.js CHANGED
@@ -1074,9 +1074,10 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
1074
1074
  // lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
1075
1075
  import { applyToPoint as applyToPoint11 } from "transformation-matrix";
1076
1076
  function createSvgObjectsFromSmtPad(pad, ctx) {
1077
- const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
1077
+ const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
1078
1078
  if (layerFilter && pad.layer !== layerFilter) return [];
1079
1079
  const isCoveredWithSolderMask = Boolean(pad?.is_covered_with_solder_mask);
1080
+ const shouldRenderSolderMask = renderSolderMask && isCoveredWithSolderMask;
1080
1081
  const solderMaskColor = colorMap2.soldermask[pad.layer] ?? colorMap2.soldermask.top;
1081
1082
  if (pad.shape === "rect" || pad.shape === "rotated_rect") {
1082
1083
  const width = pad.width * Math.abs(transform.a);
@@ -1104,7 +1105,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
1104
1105
  } : {}
1105
1106
  }
1106
1107
  };
1107
- if (!isCoveredWithSolderMask) {
1108
+ if (!shouldRenderSolderMask) {
1108
1109
  return [padElement2];
1109
1110
  }
1110
1111
  const maskElement2 = {
@@ -1139,7 +1140,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
1139
1140
  } : {}
1140
1141
  }
1141
1142
  };
1142
- if (!isCoveredWithSolderMask) {
1143
+ if (!shouldRenderSolderMask) {
1143
1144
  return [padElement];
1144
1145
  }
1145
1146
  const maskElement = {
@@ -1177,7 +1178,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
1177
1178
  "data-layer": pad.layer
1178
1179
  }
1179
1180
  };
1180
- if (!isCoveredWithSolderMask) {
1181
+ if (!shouldRenderSolderMask) {
1181
1182
  return [padElement];
1182
1183
  }
1183
1184
  const maskElement = {
@@ -1210,7 +1211,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
1210
1211
  "data-layer": pad.layer
1211
1212
  }
1212
1213
  };
1213
- if (!isCoveredWithSolderMask) {
1214
+ if (!shouldRenderSolderMask) {
1214
1215
  return [padElement];
1215
1216
  }
1216
1217
  const maskElement = {
@@ -1242,7 +1243,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
1242
1243
  "data-layer": pad.layer
1243
1244
  }
1244
1245
  };
1245
- if (!isCoveredWithSolderMask) {
1246
+ if (!shouldRenderSolderMask) {
1246
1247
  return [padElement];
1247
1248
  }
1248
1249
  const maskElement = {
@@ -1788,7 +1789,7 @@ function getSoftwareUsedString(circuitJson) {
1788
1789
  var package_default = {
1789
1790
  name: "circuit-to-svg",
1790
1791
  type: "module",
1791
- version: "0.0.222",
1792
+ version: "0.0.224",
1792
1793
  description: "Convert Circuit JSON to SVG",
1793
1794
  main: "dist/index.js",
1794
1795
  files: [
@@ -8621,16 +8622,23 @@ function createLegend(graphs, width) {
8621
8622
  return svgElement("g", { class: "legend" }, children);
8622
8623
  }
8623
8624
  function createDataGroup(graphs, clipPathId, scaleX, scaleY) {
8624
- const elements = [];
8625
- for (const entry of graphs) {
8626
- if (entry.points.length === 0) continue;
8625
+ const LINE_REPEAT_COUNT = 3;
8626
+ const DASH_PATTERN = [4, 8];
8627
+ const dashArrayString = DASH_PATTERN.map((value) => formatNumber(value)).join(
8628
+ " "
8629
+ );
8630
+ const dashCycleLength = DASH_PATTERN.reduce((sum, value) => sum + value, 0);
8631
+ const dashOffsetStep = dashCycleLength / LINE_REPEAT_COUNT;
8632
+ const processedGraphs = [];
8633
+ graphs.forEach((entry, graphIndex) => {
8634
+ if (entry.points.length === 0) return;
8627
8635
  const commands = [];
8628
8636
  entry.points.forEach((point, index) => {
8629
8637
  const x = formatNumber(scaleX(point.timeMs));
8630
8638
  const y = formatNumber(scaleY(point.voltage));
8631
8639
  commands.push(`${index === 0 ? "M" : "L"} ${x} ${y}`);
8632
8640
  });
8633
- const pathAttributes = {
8641
+ const baseAttributes = {
8634
8642
  class: "simulation-line",
8635
8643
  d: commands.join(" "),
8636
8644
  stroke: entry.color,
@@ -8638,29 +8646,52 @@ function createDataGroup(graphs, clipPathId, scaleX, scaleY) {
8638
8646
  "data-simulation-transient-voltage-graph-id": entry.graph.simulation_transient_voltage_graph_id
8639
8647
  };
8640
8648
  if (entry.graph.schematic_voltage_probe_id) {
8641
- pathAttributes["data-schematic-voltage-probe-id"] = entry.graph.schematic_voltage_probe_id;
8649
+ baseAttributes["data-schematic-voltage-probe-id"] = entry.graph.schematic_voltage_probe_id;
8642
8650
  }
8643
8651
  if (entry.graph.subcircuit_connecivity_map_key) {
8644
- pathAttributes["data-subcircuit-connectivity-map-key"] = entry.graph.subcircuit_connecivity_map_key;
8652
+ baseAttributes["data-subcircuit-connectivity-map-key"] = entry.graph.subcircuit_connecivity_map_key;
8645
8653
  }
8646
- elements.push(svgElement("path", pathAttributes));
8647
- entry.points.forEach((point) => {
8654
+ const pointElements2 = entry.points.map((point) => {
8648
8655
  const cx = formatNumber(scaleX(point.timeMs));
8649
8656
  const cy = formatNumber(scaleY(point.voltage));
8650
- elements.push(
8651
- svgElement("circle", {
8652
- class: "simulation-point",
8653
- cx,
8654
- cy,
8655
- r: "3.5",
8656
- stroke: entry.color,
8657
- fill: "#ffffff",
8658
- "clip-path": `url(#${clipPathId})`
8657
+ return svgElement("circle", {
8658
+ class: "simulation-point",
8659
+ cx,
8660
+ cy,
8661
+ r: "3.5",
8662
+ stroke: entry.color,
8663
+ fill: "#ffffff",
8664
+ "clip-path": `url(#${clipPathId})`
8665
+ });
8666
+ });
8667
+ processedGraphs.push({
8668
+ entry,
8669
+ graphIndex,
8670
+ pathAttributes: baseAttributes,
8671
+ pointElements: pointElements2
8672
+ });
8673
+ });
8674
+ const lineElements = [];
8675
+ for (let cycle = 0; cycle < LINE_REPEAT_COUNT; cycle++) {
8676
+ processedGraphs.forEach((graphInfo) => {
8677
+ const offsetIndex = (graphInfo.graphIndex + cycle) % LINE_REPEAT_COUNT;
8678
+ const dashOffset = formatNumber(offsetIndex * dashOffsetStep);
8679
+ lineElements.push(
8680
+ svgElement("path", {
8681
+ ...graphInfo.pathAttributes,
8682
+ "stroke-dasharray": dashArrayString,
8683
+ "stroke-dashoffset": dashOffset
8659
8684
  })
8660
8685
  );
8661
8686
  });
8662
8687
  }
8663
- return svgElement("g", { class: "data-series" }, elements);
8688
+ const pointElements = processedGraphs.flatMap(
8689
+ (graphInfo) => graphInfo.pointElements
8690
+ );
8691
+ return svgElement("g", { class: "data-series" }, [
8692
+ ...lineElements,
8693
+ ...pointElements
8694
+ ]);
8664
8695
  }
8665
8696
  function createTitleNode(experiment, width) {
8666
8697
  if (!experiment?.name) return null;