circuit-to-svg 0.0.314 → 0.0.315

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
@@ -3405,6 +3405,14 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3405
3405
  const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
3406
3406
  const cornerRadiusValue = pad.corner_radius ?? pad.rect_border_radius ?? 0;
3407
3407
  const scaledBorderRadius = cornerRadiusValue * Math.abs(transform.a);
3408
+ const m = {
3409
+ left: (pad.soldermask_margin_left ?? pad.soldermask_margin ?? 0) * Math.abs(transform.a),
3410
+ right: (pad.soldermask_margin_right ?? pad.soldermask_margin ?? 0) * Math.abs(transform.a),
3411
+ top: (pad.soldermask_margin_top ?? pad.soldermask_margin ?? 0) * Math.abs(transform.a),
3412
+ bottom: (pad.soldermask_margin_bottom ?? pad.soldermask_margin ?? 0) * Math.abs(transform.a)
3413
+ };
3414
+ const isNegativeMargin = m.left < 0 || m.right < 0 || m.top < 0 || m.bottom < 0;
3415
+ const isZeroMargin = m.left === 0 && m.right === 0 && m.top === 0 && m.bottom === 0;
3408
3416
  if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
3409
3417
  const padElement2 = {
3410
3418
  name: "rect",
@@ -3430,10 +3438,10 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3430
3438
  if (!shouldShowSolderMask) {
3431
3439
  return [padElement2];
3432
3440
  }
3433
- const maskWidth2 = width + 2 * soldermaskMargin;
3434
- const maskHeight2 = height + 2 * soldermaskMargin;
3441
+ const maskWidth2 = width + m.left + m.right;
3442
+ const maskHeight2 = height + m.top + m.bottom;
3435
3443
  const maskBorderRadius2 = scaledBorderRadius ? scaledBorderRadius + soldermaskMargin : 0;
3436
- if (soldermaskMargin < 0) {
3444
+ if (isNegativeMargin) {
3437
3445
  const coveredPadElement = {
3438
3446
  name: "rect",
3439
3447
  type: "element",
@@ -3463,8 +3471,8 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3463
3471
  attributes: {
3464
3472
  class: "pcb-pad-exposed",
3465
3473
  fill: layerNameToColor(pad.layer, colorMap2),
3466
- x: (-maskWidth2 / 2).toString(),
3467
- y: (-maskHeight2 / 2).toString(),
3474
+ x: (-width / 2 - m.left).toString(),
3475
+ y: (-height / 2 - m.top).toString(),
3468
3476
  width: maskWidth2.toString(),
3469
3477
  height: maskHeight2.toString(),
3470
3478
  transform: `translate(${x} ${y}) rotate(${-pad.ccw_rotation})`,
@@ -3478,7 +3486,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3478
3486
  };
3479
3487
  return [coveredPadElement, exposedOpeningElement];
3480
3488
  }
3481
- if (soldermaskMargin === 0) {
3489
+ if (isZeroMargin) {
3482
3490
  const coveredPadElement = {
3483
3491
  name: "rect",
3484
3492
  type: "element",
@@ -3510,8 +3518,8 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3510
3518
  attributes: {
3511
3519
  class: "pcb-soldermask-cutout",
3512
3520
  fill: colorMap2.substrate,
3513
- x: (-maskWidth2 / 2).toString(),
3514
- y: (-maskHeight2 / 2).toString(),
3521
+ x: (-width / 2 - m.left).toString(),
3522
+ y: (-height / 2 - m.top).toString(),
3515
3523
  width: maskWidth2.toString(),
3516
3524
  height: maskHeight2.toString(),
3517
3525
  transform: `translate(${x} ${y}) rotate(${-pad.ccw_rotation})`,
@@ -3548,10 +3556,10 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3548
3556
  if (!shouldShowSolderMask) {
3549
3557
  return [padElement];
3550
3558
  }
3551
- const maskWidth = width + 2 * soldermaskMargin;
3552
- const maskHeight = height + 2 * soldermaskMargin;
3559
+ const maskWidth = width + m.left + m.right;
3560
+ const maskHeight = height + m.top + m.bottom;
3553
3561
  const maskBorderRadius = scaledBorderRadius ? scaledBorderRadius + soldermaskMargin : 0;
3554
- if (soldermaskMargin < 0) {
3562
+ if (isNegativeMargin) {
3555
3563
  const coveredPadElement = {
3556
3564
  name: "rect",
3557
3565
  type: "element",
@@ -3580,8 +3588,8 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3580
3588
  attributes: {
3581
3589
  class: "pcb-pad-exposed",
3582
3590
  fill: layerNameToColor(pad.layer, colorMap2),
3583
- x: (x - maskWidth / 2).toString(),
3584
- y: (y - maskHeight / 2).toString(),
3591
+ x: (x - width / 2 - m.left).toString(),
3592
+ y: (y - height / 2 - m.top).toString(),
3585
3593
  width: maskWidth.toString(),
3586
3594
  height: maskHeight.toString(),
3587
3595
  "data-type": "pcb_soldermask",
@@ -3594,7 +3602,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3594
3602
  };
3595
3603
  return [coveredPadElement, exposedOpeningElement];
3596
3604
  }
3597
- if (soldermaskMargin === 0) {
3605
+ if (isZeroMargin) {
3598
3606
  const coveredPadElement = {
3599
3607
  name: "rect",
3600
3608
  type: "element",
@@ -3625,8 +3633,8 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
3625
3633
  attributes: {
3626
3634
  class: "pcb-soldermask-cutout",
3627
3635
  fill: colorMap2.substrate,
3628
- x: (x - maskWidth / 2).toString(),
3629
- y: (y - maskHeight / 2).toString(),
3636
+ x: (x - width / 2 - m.left).toString(),
3637
+ y: (y - height / 2 - m.top).toString(),
3630
3638
  width: maskWidth.toString(),
3631
3639
  height: maskHeight.toString(),
3632
3640
  ...maskBorderRadius > 0 ? {
@@ -6034,7 +6042,7 @@ function getSoftwareUsedString(circuitJson) {
6034
6042
  var package_default = {
6035
6043
  name: "circuit-to-svg",
6036
6044
  type: "module",
6037
- version: "0.0.313",
6045
+ version: "0.0.314",
6038
6046
  description: "Convert Circuit JSON to SVG",
6039
6047
  main: "dist/index.js",
6040
6048
  files: [
@@ -6057,7 +6065,7 @@ var package_default = {
6057
6065
  "@vitejs/plugin-react": "5.0.0",
6058
6066
  biome: "^0.3.3",
6059
6067
  "bun-match-svg": "^0.0.12",
6060
- "circuit-json": "^0.0.351",
6068
+ "circuit-json": "^0.0.356",
6061
6069
  esbuild: "^0.20.2",
6062
6070
  "performance-now": "^2.1.0",
6063
6071
  react: "19.1.0",