circuit-to-canvas 0.0.42 → 0.0.43

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
@@ -957,6 +957,9 @@ function layerToColor(layer, colorMap) {
957
957
  function getSoldermaskColor2(layer, colorMap) {
958
958
  return colorMap.soldermaskOverCopper[layer] ?? colorMap.soldermaskOverCopper.top;
959
959
  }
960
+ function getBorderRadius(pad, margin = 0) {
961
+ return (pad.corner_radius ?? pad.rect_border_radius ?? 0) + margin;
962
+ }
960
963
  function drawPcbSmtPad(params) {
961
964
  const { ctx, pad, realToCanvasMat, colorMap } = params;
962
965
  const color = layerToColor(pad.layer, colorMap);
@@ -975,7 +978,7 @@ function drawPcbSmtPad(params) {
975
978
  height: pad.height + margin * 2,
976
979
  fill: positiveMarginColor,
977
980
  realToCanvasMat,
978
- borderRadius: (pad.corner_radius ?? pad.rect_border_radius ?? 0) + margin
981
+ borderRadius: getBorderRadius(pad, margin)
979
982
  });
980
983
  }
981
984
  drawRect({
@@ -985,7 +988,7 @@ function drawPcbSmtPad(params) {
985
988
  height: pad.height,
986
989
  fill: color,
987
990
  realToCanvasMat,
988
- borderRadius: pad.corner_radius ?? pad.rect_border_radius ?? 0
991
+ borderRadius: getBorderRadius(pad)
989
992
  });
990
993
  if (hasSoldermask && margin < 0) {
991
994
  drawSoldermaskRingForRect(
@@ -994,7 +997,7 @@ function drawPcbSmtPad(params) {
994
997
  pad.width,
995
998
  pad.height,
996
999
  margin,
997
- pad.corner_radius ?? pad.rect_border_radius ?? 0,
1000
+ getBorderRadius(pad),
998
1001
  0,
999
1002
  realToCanvasMat,
1000
1003
  soldermaskRingColor,
@@ -1009,7 +1012,7 @@ function drawPcbSmtPad(params) {
1009
1012
  height: pad.height,
1010
1013
  fill: soldermaskOverlayColor,
1011
1014
  realToCanvasMat,
1012
- borderRadius: pad.corner_radius ?? pad.rect_border_radius ?? 0
1015
+ borderRadius: getBorderRadius(pad)
1013
1016
  });
1014
1017
  }
1015
1018
  return;
@@ -1023,7 +1026,7 @@ function drawPcbSmtPad(params) {
1023
1026
  height: pad.height + margin * 2,
1024
1027
  fill: positiveMarginColor,
1025
1028
  realToCanvasMat,
1026
- borderRadius: (pad.corner_radius ?? pad.rect_border_radius ?? 0) + margin,
1029
+ borderRadius: getBorderRadius(pad, margin),
1027
1030
  rotation: pad.ccw_rotation ?? 0
1028
1031
  });
1029
1032
  }
@@ -1034,7 +1037,7 @@ function drawPcbSmtPad(params) {
1034
1037
  height: pad.height,
1035
1038
  fill: color,
1036
1039
  realToCanvasMat,
1037
- borderRadius: pad.corner_radius ?? pad.rect_border_radius ?? 0,
1040
+ borderRadius: getBorderRadius(pad),
1038
1041
  rotation: pad.ccw_rotation ?? 0
1039
1042
  });
1040
1043
  if (hasSoldermask && margin < 0) {
@@ -1044,7 +1047,7 @@ function drawPcbSmtPad(params) {
1044
1047
  pad.width,
1045
1048
  pad.height,
1046
1049
  margin,
1047
- pad.corner_radius ?? pad.rect_border_radius ?? 0,
1050
+ getBorderRadius(pad),
1048
1051
  pad.ccw_rotation ?? 0,
1049
1052
  realToCanvasMat,
1050
1053
  soldermaskRingColor,
@@ -1059,7 +1062,7 @@ function drawPcbSmtPad(params) {
1059
1062
  height: pad.height,
1060
1063
  fill: soldermaskOverlayColor,
1061
1064
  realToCanvasMat,
1062
- borderRadius: pad.corner_radius ?? pad.rect_border_radius ?? 0,
1065
+ borderRadius: getBorderRadius(pad),
1063
1066
  rotation: pad.ccw_rotation ?? 0
1064
1067
  });
1065
1068
  }
@@ -33,6 +33,14 @@ function getSoldermaskColor(layer: string, colorMap: PcbColorMap): string {
33
33
  )
34
34
  }
35
35
 
36
+ function getBorderRadius(pad: PcbSmtPad, margin: number = 0): number {
37
+ return (
38
+ ((pad as { corner_radius?: number }).corner_radius ??
39
+ (pad as { rect_border_radius?: number }).rect_border_radius ??
40
+ 0) + margin
41
+ )
42
+ }
43
+
36
44
  export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
37
45
  const { ctx, pad, realToCanvasMat, colorMap } = params
38
46
 
@@ -62,10 +70,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
62
70
  height: pad.height + margin * 2,
63
71
  fill: positiveMarginColor,
64
72
  realToCanvasMat,
65
- borderRadius:
66
- ((pad as { corner_radius?: number }).corner_radius ??
67
- pad.rect_border_radius ??
68
- 0) + margin,
73
+ borderRadius: getBorderRadius(pad, margin),
69
74
  })
70
75
  }
71
76
 
@@ -77,10 +82,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
77
82
  height: pad.height,
78
83
  fill: color,
79
84
  realToCanvasMat,
80
- borderRadius:
81
- (pad as { corner_radius?: number }).corner_radius ??
82
- pad.rect_border_radius ??
83
- 0,
85
+ borderRadius: getBorderRadius(pad),
84
86
  })
85
87
 
86
88
  // For negative margins, draw soldermask ring on top of the pad
@@ -91,9 +93,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
91
93
  pad.width,
92
94
  pad.height,
93
95
  margin,
94
- (pad as { corner_radius?: number }).corner_radius ??
95
- pad.rect_border_radius ??
96
- 0,
96
+ getBorderRadius(pad),
97
97
  0,
98
98
  realToCanvasMat,
99
99
  soldermaskRingColor,
@@ -110,10 +110,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
110
110
  height: pad.height,
111
111
  fill: soldermaskOverlayColor,
112
112
  realToCanvasMat,
113
- borderRadius:
114
- (pad as { corner_radius?: number }).corner_radius ??
115
- pad.rect_border_radius ??
116
- 0,
113
+ borderRadius: getBorderRadius(pad),
117
114
  })
118
115
  }
119
116
  return
@@ -129,10 +126,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
129
126
  height: pad.height + margin * 2,
130
127
  fill: positiveMarginColor,
131
128
  realToCanvasMat,
132
- borderRadius:
133
- ((pad as { corner_radius?: number }).corner_radius ??
134
- pad.rect_border_radius ??
135
- 0) + margin,
129
+ borderRadius: getBorderRadius(pad, margin),
136
130
  rotation: pad.ccw_rotation ?? 0,
137
131
  })
138
132
  }
@@ -145,10 +139,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
145
139
  height: pad.height,
146
140
  fill: color,
147
141
  realToCanvasMat,
148
- borderRadius:
149
- (pad as { corner_radius?: number }).corner_radius ??
150
- pad.rect_border_radius ??
151
- 0,
142
+ borderRadius: getBorderRadius(pad),
152
143
  rotation: pad.ccw_rotation ?? 0,
153
144
  })
154
145
 
@@ -160,9 +151,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
160
151
  pad.width,
161
152
  pad.height,
162
153
  margin,
163
- (pad as { corner_radius?: number }).corner_radius ??
164
- pad.rect_border_radius ??
165
- 0,
154
+ getBorderRadius(pad),
166
155
  pad.ccw_rotation ?? 0,
167
156
  realToCanvasMat,
168
157
  soldermaskRingColor,
@@ -179,10 +168,7 @@ export function drawPcbSmtPad(params: DrawPcbSmtPadParams): void {
179
168
  height: pad.height,
180
169
  fill: soldermaskOverlayColor,
181
170
  realToCanvasMat,
182
- borderRadius:
183
- (pad as { corner_radius?: number }).corner_radius ??
184
- pad.rect_border_radius ??
185
- 0,
171
+ borderRadius: getBorderRadius(pad),
186
172
  rotation: pad.ccw_rotation ?? 0,
187
173
  })
188
174
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-to-canvas",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.42",
4
+ "version": "0.0.43",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup-node ./lib/index.ts --format esm --dts",