jscad-electronics 0.0.166 → 0.0.168

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/vanilla.js CHANGED
@@ -3241,8 +3241,41 @@ var DFN = ({
3241
3241
  padWidth = bodyLength10 / 5.3 * 0.6,
3242
3242
  padLength = bodyLength10 / 5.3 * 1,
3243
3243
  pitch = 0.5,
3244
- thermalPadThickness = 0.2
3244
+ thermalPadThickness = 0.2,
3245
+ bodyStyle = "chamfered",
3246
+ standoff = 0,
3247
+ terminalInset = 0,
3248
+ terminalThickness = thermalPadThickness,
3249
+ pin1TerminalChamfer = 0,
3250
+ pin1MarkWidth = 0
3245
3251
  }) => {
3252
+ if (bodyStyle === "rectangular") {
3253
+ if (!Number.isInteger(num_pins) || num_pins < 2 || num_pins % 2 !== 0)
3254
+ throw new Error("DFN requires an even pin count of at least two");
3255
+ for (const value of [
3256
+ bodyWidth,
3257
+ bodyLength10,
3258
+ bodyThickness,
3259
+ padWidth,
3260
+ padLength,
3261
+ pitch,
3262
+ terminalThickness
3263
+ ])
3264
+ if (!Number.isFinite(value) || value <= 0)
3265
+ throw new Error("DFN dimensions must be finite and positive");
3266
+ for (const value of [
3267
+ standoff,
3268
+ terminalInset,
3269
+ pin1TerminalChamfer,
3270
+ pin1MarkWidth
3271
+ ])
3272
+ if (!Number.isFinite(value) || value < 0)
3273
+ throw new Error("DFN offsets must be finite and nonnegative");
3274
+ if (terminalThickness <= standoff || terminalThickness > standoff + bodyThickness || terminalInset + padLength >= bodyWidth / 2 || (num_pins / 2 - 1) * pitch + padWidth > bodyLength10 || num_pins > 2 && padWidth >= pitch || pin1TerminalChamfer >= Math.min(padLength, padWidth / 2) || pin1MarkWidth >= bodyWidth / 4)
3275
+ throw new Error(
3276
+ "DFN dimensions leave disconnected or overlapping terminals"
3277
+ );
3278
+ }
3246
3279
  const pinPositions = [];
3247
3280
  const pinsPerSide = Math.floor(num_pins / 2);
3248
3281
  const pinSpan = pitch * (pinsPerSide - 1);
@@ -3252,10 +3285,88 @@ var DFN = ({
3252
3285
  const y = pinSpan / 2 - indexOnSide * pitch;
3253
3286
  const padSizeX = padLength;
3254
3287
  const padSizeY = padWidth;
3255
- const x = side === "left" ? -bodyWidth / 2 + padSizeX / 2 : bodyWidth / 2 - padSizeX / 2;
3288
+ const x = side === "left" ? -bodyWidth / 2 + padSizeX / 2 + terminalInset : bodyWidth / 2 - padSizeX / 2 - terminalInset;
3256
3289
  const pinNumber = i + 1;
3257
3290
  pinPositions.push({ pinNumber, x, y, padSizeX, padSizeY });
3258
3291
  }
3292
+ if (bodyStyle === "rectangular") {
3293
+ const top = standoff + bodyThickness;
3294
+ const inkThickness = Math.min(bodyThickness, bodyLength10) / 100;
3295
+ const stripe = /* @__PURE__ */ jsx(
3296
+ Cuboid,
3297
+ {
3298
+ size: [pin1MarkWidth, bodyLength10 * 0.8, inkThickness],
3299
+ center: [
3300
+ -bodyWidth / 2 + pin1MarkWidth * 1.5,
3301
+ 0,
3302
+ top - inkThickness / 2
3303
+ ]
3304
+ }
3305
+ );
3306
+ const body = /* @__PURE__ */ jsx(
3307
+ Cuboid,
3308
+ {
3309
+ size: [bodyWidth, bodyLength10, bodyThickness],
3310
+ center: [0, 0, standoff + bodyThickness / 2]
3311
+ }
3312
+ );
3313
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
3314
+ /* @__PURE__ */ jsx(Colorize, { color: "#25272a", children: pin1MarkWidth > 0 ? /* @__PURE__ */ jsxs(Subtract, { children: [
3315
+ body,
3316
+ stripe
3317
+ ] }) : body }),
3318
+ /* @__PURE__ */ jsx(Colorize, { color: "#c7c9cd", children: pinPositions.map(
3319
+ (p) => p.pinNumber === 1 && pin1TerminalChamfer > 0 ? /* @__PURE__ */ jsxs(Hull, { children: [
3320
+ /* @__PURE__ */ jsx(
3321
+ Cuboid,
3322
+ {
3323
+ size: [
3324
+ padLength - pin1TerminalChamfer,
3325
+ padWidth,
3326
+ terminalThickness
3327
+ ],
3328
+ center: [
3329
+ p.x + pin1TerminalChamfer / 2,
3330
+ p.y,
3331
+ terminalThickness / 2
3332
+ ]
3333
+ }
3334
+ ),
3335
+ /* @__PURE__ */ jsx(
3336
+ Cuboid,
3337
+ {
3338
+ size: [
3339
+ padLength,
3340
+ padWidth - 2 * pin1TerminalChamfer,
3341
+ terminalThickness
3342
+ ],
3343
+ center: [p.x, p.y, terminalThickness / 2]
3344
+ }
3345
+ )
3346
+ ] }, p.pinNumber) : /* @__PURE__ */ jsx(
3347
+ Cuboid,
3348
+ {
3349
+ size: [p.padSizeX, p.padSizeY, terminalThickness],
3350
+ center: [p.x, p.y, terminalThickness / 2]
3351
+ },
3352
+ p.pinNumber
3353
+ )
3354
+ ) }),
3355
+ thermalPadSize && /* @__PURE__ */ jsx(
3356
+ Cuboid,
3357
+ {
3358
+ color: "#c7c9cd",
3359
+ size: [
3360
+ thermalPadSize.width,
3361
+ thermalPadSize.length,
3362
+ thermalPadThickness
3363
+ ],
3364
+ center: [0, 0, thermalPadThickness / 2]
3365
+ }
3366
+ ),
3367
+ pin1MarkWidth > 0 && /* @__PURE__ */ jsx(Colorize, { color: "#969997", children: stripe })
3368
+ ] });
3369
+ }
3259
3370
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
3260
3371
  /* @__PURE__ */ jsx(
3261
3372
  ChipBody,