circuit-to-svg 0.0.270 → 0.0.271

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
@@ -2804,10 +2804,25 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
2804
2804
  const { transform, colorMap: colorMap2, showSolderMask } = ctx;
2805
2805
  const width = Number(pcbPanel.width);
2806
2806
  const height = Number(pcbPanel.height);
2807
- const topLeft = applyToPoint22(transform, [0, 0]);
2808
- const topRight = applyToPoint22(transform, [width, 0]);
2809
- const bottomRight = applyToPoint22(transform, [width, height]);
2810
- const bottomLeft = applyToPoint22(transform, [0, height]);
2807
+ const center = pcbPanel.center ?? { x: width / 2, y: height / 2 };
2808
+ const halfWidth = width / 2;
2809
+ const halfHeight = height / 2;
2810
+ const topLeft = applyToPoint22(transform, [
2811
+ center.x - halfWidth,
2812
+ center.y - halfHeight
2813
+ ]);
2814
+ const topRight = applyToPoint22(transform, [
2815
+ center.x + halfWidth,
2816
+ center.y - halfHeight
2817
+ ]);
2818
+ const bottomRight = applyToPoint22(transform, [
2819
+ center.x + halfWidth,
2820
+ center.y + halfHeight
2821
+ ]);
2822
+ const bottomLeft = applyToPoint22(transform, [
2823
+ center.x - halfWidth,
2824
+ center.y + halfHeight
2825
+ ]);
2811
2826
  const path = `M ${topLeft[0]} ${topLeft[1]} L ${topRight[0]} ${topRight[1]} L ${bottomRight[0]} ${bottomRight[1]} L ${bottomLeft[0]} ${bottomLeft[1]} Z`;
2812
2827
  const isCoveredWithSolderMask = pcbPanel.covered_with_solder_mask !== false;
2813
2828
  const shouldshowSolderMask = Boolean(
@@ -3963,7 +3978,7 @@ function getSoftwareUsedString(circuitJson) {
3963
3978
  var package_default = {
3964
3979
  name: "circuit-to-svg",
3965
3980
  type: "module",
3966
- version: "0.0.269",
3981
+ version: "0.0.270",
3967
3982
  description: "Convert Circuit JSON to SVG",
3968
3983
  main: "dist/index.js",
3969
3984
  files: [
@@ -4184,7 +4199,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
4184
4199
  if (width === void 0 || height === void 0) {
4185
4200
  continue;
4186
4201
  }
4187
- const center = { x: width / 2, y: height / 2 };
4202
+ const center = panel.center ?? { x: width / 2, y: height / 2 };
4188
4203
  updateBounds(center, width, height);
4189
4204
  } else if (circuitJsonElm.type === "pcb_board") {
4190
4205
  if (circuitJsonElm.outline && Array.isArray(circuitJsonElm.outline) && circuitJsonElm.outline.length >= 3) {
@@ -11291,7 +11306,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
11291
11306
  const width = distance2.parse(panel.width);
11292
11307
  const height = distance2.parse(panel.height);
11293
11308
  if (width !== void 0 && height !== void 0) {
11294
- updateBounds({ x: width / 2, y: height / 2 }, width, height);
11309
+ const center = panel.center ?? { x: width / 2, y: height / 2 };
11310
+ updateBounds(center, width, height);
11295
11311
  }
11296
11312
  } else if (item.type === "pcb_solder_paste" && "x" in item && "y" in item) {
11297
11313
  updateBounds({ x: item.x, y: item.y }, 0, 0);