circuit-to-svg 0.0.313 → 0.0.314

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
@@ -6034,7 +6034,7 @@ function getSoftwareUsedString(circuitJson) {
6034
6034
  var package_default = {
6035
6035
  name: "circuit-to-svg",
6036
6036
  type: "module",
6037
- version: "0.0.312",
6037
+ version: "0.0.313",
6038
6038
  description: "Convert Circuit JSON to SVG",
6039
6039
  main: "dist/index.js",
6040
6040
  files: [
@@ -10487,6 +10487,10 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
10487
10487
  { width: item.radius * 2, height: item.radius * 2 },
10488
10488
  0
10489
10489
  );
10490
+ } else if (item.type === "schematic_path") {
10491
+ for (const point of item.points) {
10492
+ updateBounds(point, { width: 0.02, height: 0.02 }, 0);
10493
+ }
10490
10494
  }
10491
10495
  }
10492
10496
  minX -= padding;
@@ -12683,6 +12687,44 @@ function createSvgObjectsFromSchematicArc({
12683
12687
  ];
12684
12688
  }
12685
12689
 
12690
+ // lib/sch/svg-object-fns/create-svg-objects-from-sch-path.ts
12691
+ import { applyToPoint as applyToPoint75 } from "transformation-matrix";
12692
+ function createSvgObjectsFromSchematicPath({
12693
+ schPath,
12694
+ transform,
12695
+ colorMap: colorMap2
12696
+ }) {
12697
+ if (!schPath.points || schPath.points.length < 2) {
12698
+ return [];
12699
+ }
12700
+ const transformedPoints = schPath.points.map(
12701
+ (p) => applyToPoint75(transform, { x: p.x, y: p.y })
12702
+ );
12703
+ const pathD = transformedPoints.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
12704
+ const strokeColor = colorMap2.schematic.component_outline;
12705
+ const fillColor = schPath.fill_color ?? "none";
12706
+ const strokeWidth = Math.abs(transform.a) * 0.02;
12707
+ return [
12708
+ {
12709
+ name: "path",
12710
+ type: "element",
12711
+ attributes: {
12712
+ d: pathD,
12713
+ stroke: strokeColor,
12714
+ "stroke-width": strokeWidth.toString(),
12715
+ fill: schPath.is_filled ? fillColor : "none",
12716
+ "stroke-linecap": "round",
12717
+ "stroke-linejoin": "round",
12718
+ ...schPath.schematic_component_id && {
12719
+ "data-schematic-component-id": schPath.schematic_component_id
12720
+ }
12721
+ },
12722
+ children: [],
12723
+ value: ""
12724
+ }
12725
+ ];
12726
+ }
12727
+
12686
12728
  // lib/sch/convert-circuit-json-to-schematic-svg.ts
12687
12729
  function buildNetHoverStyles(connectivityKeys) {
12688
12730
  const rules = [];
@@ -12777,6 +12819,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
12777
12819
  const schCircleSvgs = [];
12778
12820
  const schRectSvgs = [];
12779
12821
  const schArcSvgs = [];
12822
+ const schPathSvgs = [];
12780
12823
  for (const elm of circuitJson) {
12781
12824
  if (elm.type === "schematic_debug_object") {
12782
12825
  schDebugObjectSvgs.push(
@@ -12883,6 +12926,14 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
12883
12926
  colorMap: colorMap2
12884
12927
  })
12885
12928
  );
12929
+ } else if (elm.type === "schematic_path") {
12930
+ schPathSvgs.push(
12931
+ ...createSvgObjectsFromSchematicPath({
12932
+ schPath: elm,
12933
+ transform,
12934
+ colorMap: colorMap2
12935
+ })
12936
+ );
12886
12937
  }
12887
12938
  }
12888
12939
  const schTraceBaseSvgs = schTraceSvgs.filter(
@@ -12899,6 +12950,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
12899
12950
  ...schCircleSvgs,
12900
12951
  ...schRectSvgs,
12901
12952
  ...schArcSvgs,
12953
+ ...schPathSvgs,
12902
12954
  ...schComponentSvgs,
12903
12955
  ...schPortHoverSvgs,
12904
12956
  ...schNetLabel,
@@ -13760,18 +13812,18 @@ function formatNumber2(value) {
13760
13812
  import { distance as distance5 } from "circuit-json";
13761
13813
  import { stringify as stringify7 } from "svgson";
13762
13814
  import {
13763
- applyToPoint as applyToPoint77,
13815
+ applyToPoint as applyToPoint78,
13764
13816
  compose as compose16,
13765
13817
  scale as scale9,
13766
13818
  translate as translate16
13767
13819
  } from "transformation-matrix";
13768
13820
 
13769
13821
  // lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
13770
- import { applyToPoint as applyToPoint76 } from "transformation-matrix";
13822
+ import { applyToPoint as applyToPoint77 } from "transformation-matrix";
13771
13823
  function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
13772
13824
  const { transform, layer: layerFilter } = ctx;
13773
13825
  if (layerFilter && solderPaste.layer !== layerFilter) return [];
13774
- const [x, y] = applyToPoint76(transform, [solderPaste.x, solderPaste.y]);
13826
+ const [x, y] = applyToPoint77(transform, [solderPaste.x, solderPaste.y]);
13775
13827
  if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
13776
13828
  const width = solderPaste.width * Math.abs(transform.a);
13777
13829
  const height = solderPaste.height * Math.abs(transform.d);
@@ -13997,8 +14049,8 @@ function createSvgObjects4({ elm, ctx }) {
13997
14049
  }
13998
14050
  }
13999
14051
  function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
14000
- const [x1, y1] = applyToPoint77(transform, [minX, minY]);
14001
- const [x2, y2] = applyToPoint77(transform, [maxX, maxY]);
14052
+ const [x1, y1] = applyToPoint78(transform, [minX, minY]);
14053
+ const [x2, y2] = applyToPoint78(transform, [maxX, maxY]);
14002
14054
  const width = Math.abs(x2 - x1);
14003
14055
  const height = Math.abs(y2 - y1);
14004
14056
  const x = Math.min(x1, x2);