jscad-electronics 0.0.143 → 0.0.145

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
@@ -4777,6 +4777,142 @@ var JSTZH1_5mm = ({
4777
4777
  ] });
4778
4778
  };
4779
4779
 
4780
+ // lib/Crystal.tsx
4781
+ var getTerminalPoints = ([centerX, centerY], width10, length, chamfer, isPinOne) => {
4782
+ const xDirection = Math.sign(centerX);
4783
+ const yDirection = Math.sign(centerY);
4784
+ const halfWidth = width10 / 2;
4785
+ const halfLength = length / 2;
4786
+ const innerChamfer = isPinOne ? Math.min(0.32, length * 0.36) : 0;
4787
+ const outerChamfer = Math.min(chamfer, halfWidth, halfLength);
4788
+ const points = [
4789
+ [-halfWidth, -halfLength],
4790
+ [halfWidth, -halfLength],
4791
+ [halfWidth, halfLength - outerChamfer],
4792
+ [halfWidth - outerChamfer, halfLength],
4793
+ [-halfWidth, halfLength]
4794
+ ];
4795
+ if (innerChamfer) {
4796
+ points[0] = [-halfWidth + innerChamfer, -halfLength];
4797
+ points.push([-halfWidth, -halfLength + innerChamfer]);
4798
+ }
4799
+ const oriented = points.map(
4800
+ ([x, y]) => [centerX + x * xDirection, centerY + y * yDirection]
4801
+ );
4802
+ return xDirection * yDirection < 0 ? oriented.reverse() : oriented;
4803
+ };
4804
+ var getRoundedRectProfile = ({
4805
+ width: width10,
4806
+ length,
4807
+ radius,
4808
+ height: height10,
4809
+ z
4810
+ }) => {
4811
+ const x = width10 / 2 - radius;
4812
+ const y = length / 2 - radius;
4813
+ return [
4814
+ [-x, -y],
4815
+ [x, -y],
4816
+ [x, y],
4817
+ [-x, y]
4818
+ ].map(([cornerX, cornerY], index) => /* @__PURE__ */ jsx(
4819
+ Cylinder,
4820
+ {
4821
+ center: [cornerX, cornerY, z + height10 / 2],
4822
+ height: height10,
4823
+ radius
4824
+ },
4825
+ `${z}-${index}`
4826
+ ));
4827
+ };
4828
+ var Crystal = ({
4829
+ horizontalPadPitch = 2.2,
4830
+ verticalPadPitch = 1.7,
4831
+ padWidth = 1.4,
4832
+ padHeight = 1.2,
4833
+ bodyHeight = 0.7
4834
+ }) => {
4835
+ const bodyWidth = horizontalPadPitch + padWidth * (5 / 7);
4836
+ const bodyLength10 = verticalPadPitch + padHeight * (2 / 3);
4837
+ const terminalThickness = Math.min(0.01, bodyHeight * 0.02);
4838
+ const terminalWidth = padWidth * (5 / 7);
4839
+ const terminalLength = padHeight * 0.75;
4840
+ const ceramicTopZ = bodyHeight * (5 / 7);
4841
+ const baseHeight = ceramicTopZ - terminalThickness;
4842
+ const sealHeight = bodyHeight * (2 / 35);
4843
+ const sealWidth = bodyWidth * 0.95;
4844
+ const sealLength = bodyLength10 * 0.94;
4845
+ const lidShoulderWidth = bodyWidth * 0.905;
4846
+ const lidShoulderLength = bodyLength10 * 0.9;
4847
+ const lidTopWidth = bodyWidth * 0.83;
4848
+ const lidTopLength = bodyLength10 * 0.82;
4849
+ const lidBaseZ = ceramicTopZ + sealHeight;
4850
+ const lidProfileHeight = Math.min(0.01, bodyHeight * 0.015);
4851
+ const bodyChamfer = Math.min(0.12, bodyLength10 * 0.05);
4852
+ const terminalX = (bodyWidth - terminalWidth) / 2;
4853
+ const terminalY = (bodyLength10 - terminalLength) / 2;
4854
+ const terminalPositions = [
4855
+ [-terminalX, -terminalY],
4856
+ [terminalX, -terminalY],
4857
+ [terminalX, terminalY],
4858
+ [-terminalX, terminalY]
4859
+ ];
4860
+ const sealProfile = getRoundedRectProfile({
4861
+ width: sealWidth,
4862
+ length: sealLength,
4863
+ radius: Math.min(0.13, sealLength * 0.08),
4864
+ height: sealHeight,
4865
+ z: ceramicTopZ
4866
+ });
4867
+ const lidProfiles = [
4868
+ ...getRoundedRectProfile({
4869
+ width: lidShoulderWidth,
4870
+ length: lidShoulderLength,
4871
+ radius: Math.min(0.14, lidShoulderLength * 0.08),
4872
+ height: lidProfileHeight,
4873
+ z: lidBaseZ
4874
+ }),
4875
+ ...getRoundedRectProfile({
4876
+ width: lidTopWidth,
4877
+ length: lidTopLength,
4878
+ radius: Math.min(0.15, lidTopLength * 0.09),
4879
+ height: lidProfileHeight,
4880
+ z: bodyHeight - lidProfileHeight
4881
+ })
4882
+ ];
4883
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
4884
+ terminalPositions.map((center, index) => /* @__PURE__ */ jsx(Colorize, { color: "#d6a258", children: /* @__PURE__ */ jsx(ExtrudeLinear, { height: terminalThickness, children: /* @__PURE__ */ jsx(
4885
+ Polygon,
4886
+ {
4887
+ points: getTerminalPoints(
4888
+ center,
4889
+ terminalWidth,
4890
+ terminalLength,
4891
+ bodyChamfer,
4892
+ index === 0
4893
+ )
4894
+ }
4895
+ ) }) }, index)),
4896
+ /* @__PURE__ */ jsx(
4897
+ ChipBody,
4898
+ {
4899
+ center: { x: 0, y: 0, z: terminalThickness },
4900
+ width: bodyWidth,
4901
+ length: bodyLength10,
4902
+ height: baseHeight - 5e-3,
4903
+ heightAboveSurface: 0,
4904
+ color: "#34343d",
4905
+ taperRatio: 0,
4906
+ straightHeightRatio: 1,
4907
+ includeNotch: false,
4908
+ chamferSize: bodyChamfer
4909
+ }
4910
+ ),
4911
+ /* @__PURE__ */ jsx(Colorize, { color: "#d2a057", children: /* @__PURE__ */ jsx(Hull, { children: sealProfile }) }),
4912
+ /* @__PURE__ */ jsx(Colorize, { color: "#b9bec2", children: /* @__PURE__ */ jsx(Hull, { children: lidProfiles }) })
4913
+ ] });
4914
+ };
4915
+
4780
4916
  // lib/FPC.tsx
4781
4917
  var HOUSING_COLOR = "#303339";
4782
4918
  var HOUSING_SHADOW = "#1f2227";
@@ -5114,6 +5250,48 @@ var SmdPinHeader = ({
5114
5250
  }) });
5115
5251
  };
5116
5252
 
5253
+ // lib/Footprinter3d.tsx
5254
+ import { mm } from "@tscircuit/mm";
5255
+
5256
+ // lib/ParametricChip.tsx
5257
+ var ParametricChip = ({
5258
+ padPitch,
5259
+ padHeight,
5260
+ color = "#333"
5261
+ }) => {
5262
+ const fullLength10 = padPitch;
5263
+ const width10 = padHeight * 0.85;
5264
+ const height10 = width10;
5265
+ const terminatorWidth9 = fullLength10 * 0.2;
5266
+ const bodyLength10 = fullLength10 - terminatorWidth9 * 2;
5267
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
5268
+ /* @__PURE__ */ jsx(
5269
+ Cuboid,
5270
+ {
5271
+ size: [bodyLength10, width10, height10],
5272
+ offset: [0, 0, height10 / 2],
5273
+ color
5274
+ }
5275
+ ),
5276
+ /* @__PURE__ */ jsx(
5277
+ Cuboid,
5278
+ {
5279
+ size: [terminatorWidth9, height10, width10],
5280
+ offset: [fullLength10 / 2 - terminatorWidth9 / 2, 0, height10 / 2],
5281
+ color: "#ccc"
5282
+ }
5283
+ ),
5284
+ /* @__PURE__ */ jsx(
5285
+ Cuboid,
5286
+ {
5287
+ size: [terminatorWidth9, height10, width10],
5288
+ offset: [-fullLength10 / 2 + terminatorWidth9 / 2, 0, height10 / 2],
5289
+ color: "#ccc"
5290
+ }
5291
+ )
5292
+ ] });
5293
+ };
5294
+
5117
5295
  // lib/Led5050.tsx
5118
5296
  var Led5050 = ({
5119
5297
  color = "#ffff00",
@@ -5442,6 +5620,16 @@ var Footprinter3d = ({ footprint }) => {
5442
5620
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
5443
5621
  const color = colorMatch ? colorMatch[1] : void 0;
5444
5622
  switch (fpJson.fn) {
5623
+ case "crystal":
5624
+ return /* @__PURE__ */ jsx(
5625
+ Crystal,
5626
+ {
5627
+ horizontalPadPitch: fpJson.px,
5628
+ verticalPadPitch: fpJson.py,
5629
+ padWidth: fpJson.pw,
5630
+ padHeight: fpJson.ph
5631
+ }
5632
+ );
5445
5633
  case "dip":
5446
5634
  return /* @__PURE__ */ jsx(Dip, { numPins: fpJson.num_pins, pitch: fpJson.p, bodyWidth: fpJson.w });
5447
5635
  case "axial":
@@ -5589,6 +5777,7 @@ var Footprinter3d = ({ footprint }) => {
5589
5777
  case "2512":
5590
5778
  return /* @__PURE__ */ jsx(A2512, { color: "#856c4d" });
5591
5779
  }
5780
+ break;
5592
5781
  }
5593
5782
  case "sot235":
5594
5783
  return /* @__PURE__ */ jsx(SOT_235_default, {});
@@ -5810,6 +5999,20 @@ var Footprinter3d = ({ footprint }) => {
5810
5999
  case "2512":
5811
6000
  return /* @__PURE__ */ jsx(A2512, { color });
5812
6001
  }
6002
+ if ((fpJson.fn === "res" || fpJson.fn === "cap") && fpJson.p !== void 0 && fpJson.ph !== void 0) {
6003
+ const padPitch = mm(fpJson.p);
6004
+ const padHeight = mm(fpJson.ph);
6005
+ if (Number.isFinite(padPitch) && Number.isFinite(padHeight)) {
6006
+ return /* @__PURE__ */ jsx(
6007
+ ParametricChip,
6008
+ {
6009
+ padPitch,
6010
+ padHeight,
6011
+ color: color ?? (fpJson.fn === "cap" ? "#856c4d" : void 0)
6012
+ }
6013
+ );
6014
+ }
6015
+ }
5813
6016
  return null;
5814
6017
  };
5815
6018