circuit-to-svg 0.0.137 → 0.0.138

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
@@ -2454,7 +2454,10 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
2454
2454
  updateBounds(item.position, { width: 0.2, height: 0.4 }, 0);
2455
2455
  } else if (item.type === "schematic_box") {
2456
2456
  updateBounds(
2457
- { x: item.x, y: item.y },
2457
+ {
2458
+ x: item.x + item.width / 2,
2459
+ y: item.y + item.height / 2
2460
+ },
2458
2461
  { width: item.width, height: item.height },
2459
2462
  0
2460
2463
  );
@@ -4729,6 +4732,49 @@ var createSvgObjectsForSchNetLabel = ({
4729
4732
  return svgObjects;
4730
4733
  };
4731
4734
 
4735
+ // lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
4736
+ import { applyToPoint as applyToPoint37 } from "transformation-matrix";
4737
+ var createSvgObjectsFromSchematicBox = ({
4738
+ schematicBox,
4739
+ transform,
4740
+ colorMap: colorMap2
4741
+ }) => {
4742
+ const topLeft = applyToPoint37(transform, {
4743
+ x: schematicBox.x,
4744
+ y: schematicBox.y
4745
+ });
4746
+ const bottomRight = applyToPoint37(transform, {
4747
+ x: schematicBox.x + schematicBox.width,
4748
+ y: schematicBox.y + schematicBox.height
4749
+ });
4750
+ const yTop = Math.min(topLeft.y, bottomRight.y);
4751
+ const yBottom = Math.max(topLeft.y, bottomRight.y);
4752
+ const xLeft = Math.min(topLeft.x, bottomRight.x);
4753
+ const xRight = Math.max(topLeft.x, bottomRight.x);
4754
+ const attributes = {
4755
+ class: "schematic-box",
4756
+ x: xLeft.toString(),
4757
+ y: yTop.toString(),
4758
+ width: (xRight - xLeft).toString(),
4759
+ height: (yBottom - yTop).toString(),
4760
+ "stroke-width": "2px",
4761
+ stroke: colorMap2.schematic.component_outline || "black",
4762
+ fill: "transparent"
4763
+ };
4764
+ if (schematicBox.is_dashed) {
4765
+ attributes["stroke-dasharray"] = "20 8";
4766
+ }
4767
+ return [
4768
+ {
4769
+ name: "rect",
4770
+ type: "element",
4771
+ value: "",
4772
+ attributes,
4773
+ children: []
4774
+ }
4775
+ ];
4776
+ };
4777
+
4732
4778
  // lib/sch/convert-circuit-json-to-schematic-svg.ts
4733
4779
  function convertCircuitJsonToSchematicSvg(circuitJson, options) {
4734
4780
  const realBounds = getSchematicBoundsFromCircuitJson(circuitJson);
@@ -4798,6 +4844,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
4798
4844
  const schNetLabel = [];
4799
4845
  const schText = [];
4800
4846
  const voltageProbeSvgs = [];
4847
+ const schBoxSvgs = [];
4801
4848
  for (const elm of circuitJson) {
4802
4849
  if (elm.type === "schematic_debug_object") {
4803
4850
  schDebugObjectSvgs.push(
@@ -4815,6 +4862,14 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
4815
4862
  colorMap: colorMap2
4816
4863
  })
4817
4864
  );
4865
+ } else if (elm.type === "schematic_box") {
4866
+ schBoxSvgs.push(
4867
+ ...createSvgObjectsFromSchematicBox({
4868
+ schematicBox: elm,
4869
+ transform,
4870
+ colorMap: colorMap2
4871
+ })
4872
+ );
4818
4873
  } else if (elm.type === "schematic_trace") {
4819
4874
  schTraceSvgs.push(
4820
4875
  ...createSchematicTrace({
@@ -4855,6 +4910,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
4855
4910
  ...schTraceSvgs,
4856
4911
  ...schNetLabel,
4857
4912
  ...schText,
4913
+ ...schBoxSvgs,
4858
4914
  ...voltageProbeSvgs
4859
4915
  );
4860
4916
  if (options?.labeledPoints) {
@@ -4921,18 +4977,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
4921
4977
  // lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
4922
4978
  import { stringify as stringify4 } from "svgson";
4923
4979
  import {
4924
- applyToPoint as applyToPoint39,
4980
+ applyToPoint as applyToPoint40,
4925
4981
  compose as compose11,
4926
4982
  scale as scale8,
4927
4983
  translate as translate11
4928
4984
  } from "transformation-matrix";
4929
4985
 
4930
4986
  // lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
4931
- import { applyToPoint as applyToPoint38 } from "transformation-matrix";
4987
+ import { applyToPoint as applyToPoint39 } from "transformation-matrix";
4932
4988
  function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
4933
4989
  const { transform, layer: layerFilter } = ctx;
4934
4990
  if (layerFilter && solderPaste.layer !== layerFilter) return [];
4935
- const [x, y] = applyToPoint38(transform, [solderPaste.x, solderPaste.y]);
4991
+ const [x, y] = applyToPoint39(transform, [solderPaste.x, solderPaste.y]);
4936
4992
  if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
4937
4993
  const width = solderPaste.width * Math.abs(transform.a);
4938
4994
  const height = solderPaste.height * Math.abs(transform.d);
@@ -5126,8 +5182,8 @@ function createSvgObjects3({ elm, ctx }) {
5126
5182
  }
5127
5183
  }
5128
5184
  function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
5129
- const [x1, y1] = applyToPoint39(transform, [minX, minY]);
5130
- const [x2, y2] = applyToPoint39(transform, [maxX, maxY]);
5185
+ const [x1, y1] = applyToPoint40(transform, [minX, minY]);
5186
+ const [x2, y2] = applyToPoint40(transform, [maxX, maxY]);
5131
5187
  const width = Math.abs(x2 - x1);
5132
5188
  const height = Math.abs(y2 - y1);
5133
5189
  const x = Math.min(x1, x2);