@tscircuit/core 0.0.1193 → 0.0.1195

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.d.ts CHANGED
@@ -73,6 +73,7 @@ type Obstacle = {
73
73
  };
74
74
  width: number;
75
75
  height: number;
76
+ ccwRotationDegrees?: number;
76
77
  connectedTo: string[];
77
78
  isCopperPour?: boolean;
78
79
  netIsAssignable?: boolean;
package/dist/index.js CHANGED
@@ -2780,9 +2780,23 @@ var getObstaclesFromCircuitJson = (soup, connMap) => {
2780
2780
  center: rect.center,
2781
2781
  width: rect.width,
2782
2782
  height: rect.height,
2783
+ ...singleRect ? {} : { ccwRotationDegrees: element.ccw_rotation },
2783
2784
  connectedTo: withNetId([element.pcb_smtpad_id])
2784
2785
  });
2785
2786
  }
2787
+ } else if (element.shape === "pill" || element.shape === "rotated_pill") {
2788
+ obstacles.push({
2789
+ type: "rect",
2790
+ layers: [element.layer],
2791
+ center: {
2792
+ x: element.x,
2793
+ y: element.y
2794
+ },
2795
+ width: element.width,
2796
+ height: element.height,
2797
+ ...element.shape === "rotated_pill" ? { ccwRotationDegrees: element.ccw_rotation } : {},
2798
+ connectedTo: withNetId([element.pcb_smtpad_id])
2799
+ });
2786
2800
  }
2787
2801
  } else if (element.type === "pcb_keepout") {
2788
2802
  if (element.shape === "circle") {
@@ -2870,6 +2884,19 @@ var getObstaclesFromCircuitJson = (soup, connMap) => {
2870
2884
  height: element.hole_height,
2871
2885
  connectedTo: []
2872
2886
  });
2887
+ } else if (element.hole_shape === "pill" || element.hole_shape === "rotated_pill") {
2888
+ obstacles.push({
2889
+ type: "rect",
2890
+ layers: EVERY_LAYER,
2891
+ center: {
2892
+ x: element.x,
2893
+ y: element.y
2894
+ },
2895
+ width: element.hole_width,
2896
+ height: element.hole_height,
2897
+ ...element.hole_shape === "rotated_pill" ? { ccwRotationDegrees: element.ccw_rotation } : {},
2898
+ connectedTo: []
2899
+ });
2873
2900
  } else if (element.hole_shape === "rect") {
2874
2901
  obstacles.push({
2875
2902
  type: "rect",
@@ -2937,7 +2964,7 @@ var getObstaclesFromCircuitJson = (soup, connMap) => {
2937
2964
  height: element.rect_pad_height,
2938
2965
  connectedTo: withNetId([element.pcb_plated_hole_id])
2939
2966
  });
2940
- } else if (element.shape === "oval" || element.shape === "pill") {
2967
+ } else if (element.shape === "oval") {
2941
2968
  obstacles.push({
2942
2969
  // @ts-ignore
2943
2970
  type: "oval",
@@ -2950,6 +2977,19 @@ var getObstaclesFromCircuitJson = (soup, connMap) => {
2950
2977
  height: element.outer_height,
2951
2978
  connectedTo: withNetId([element.pcb_plated_hole_id])
2952
2979
  });
2980
+ } else if (element.shape === "pill") {
2981
+ obstacles.push({
2982
+ type: "rect",
2983
+ layers: EVERY_LAYER,
2984
+ center: {
2985
+ x: element.x,
2986
+ y: element.y
2987
+ },
2988
+ width: element.outer_width,
2989
+ height: element.outer_height,
2990
+ ccwRotationDegrees: element.ccw_rotation,
2991
+ connectedTo: withNetId([element.pcb_plated_hole_id])
2992
+ });
2953
2993
  } else if (element.shape === "hole_with_polygon_pad") {
2954
2994
  if ("pad_outline" in element && element.pad_outline && element.pad_outline.length > 0) {
2955
2995
  const xs = element.pad_outline.map((p) => element.x + p.x);
@@ -7718,6 +7758,29 @@ import {
7718
7758
  distance as distance5
7719
7759
  } from "circuit-json";
7720
7760
  import { applyToPoint as applyToPoint15, decomposeTSR as decomposeTSR6 } from "transformation-matrix";
7761
+
7762
+ // lib/utils/pcb/get-axis-aligned-size-from-rotated-rect.ts
7763
+ function getAxisAlignedSizeFromRotatedRect({
7764
+ width,
7765
+ height,
7766
+ ccwRotationDegrees
7767
+ }) {
7768
+ const angleRad = ccwRotationDegrees * Math.PI / 180;
7769
+ const cosAngle = Math.cos(angleRad);
7770
+ const sinAngle = Math.sin(angleRad);
7771
+ const w2 = width / 2;
7772
+ const h2 = height / 2;
7773
+ const xExtent = Math.abs(w2 * cosAngle) + Math.abs(h2 * sinAngle);
7774
+ const yExtent = Math.abs(w2 * sinAngle) + Math.abs(h2 * cosAngle);
7775
+ return {
7776
+ width: xExtent * 2,
7777
+ height: yExtent * 2,
7778
+ xExtent,
7779
+ yExtent
7780
+ };
7781
+ }
7782
+
7783
+ // lib/components/primitive-components/SmtPad.ts
7721
7784
  var SmtPad = class extends PrimitiveComponent2 {
7722
7785
  pcb_smtpad_id = null;
7723
7786
  matchedPort = null;
@@ -7737,12 +7800,11 @@ var SmtPad = class extends PrimitiveComponent2 {
7737
7800
  return { width: props.width, height: props.height };
7738
7801
  }
7739
7802
  if (props.shape === "rotated_rect") {
7740
- const rotationDegrees = props.ccwRotation ?? 0;
7741
- const angleRad = rotationDegrees * Math.PI / 180;
7742
- const cosAngle = Math.cos(angleRad);
7743
- const sinAngle = Math.sin(angleRad);
7744
- const width = Math.abs(props.width * cosAngle) + Math.abs(props.height * sinAngle);
7745
- const height = Math.abs(props.width * sinAngle) + Math.abs(props.height * cosAngle);
7803
+ const { width, height } = getAxisAlignedSizeFromRotatedRect({
7804
+ width: props.width,
7805
+ height: props.height,
7806
+ ccwRotationDegrees: props.ccwRotation ?? 0
7807
+ });
7746
7808
  return { width, height };
7747
7809
  }
7748
7810
  if (props.shape === "polygon") {
@@ -7961,23 +8023,44 @@ var SmtPad = class extends PrimitiveComponent2 {
7961
8023
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
7962
8024
  });
7963
8025
  } else if (props.shape === "pill") {
7964
- pcb_smtpad = db.pcb_smtpad.insert({
7965
- pcb_component_id,
7966
- pcb_port_id: this.matchedPort?.pcb_port_id,
7967
- // port likely isn't matched
7968
- layer: maybeFlipLayer(props.layer ?? "top"),
7969
- shape: "pill",
7970
- x: position.x,
7971
- y: position.y,
7972
- radius: props.radius,
7973
- height: props.height,
7974
- width: props.width,
7975
- port_hints: portHints,
7976
- is_covered_with_solder_mask: isCoveredWithSolderMask,
7977
- soldermask_margin: soldermaskMargin,
7978
- subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
7979
- pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
7980
- });
8026
+ if (finalRotationDegrees !== 0) {
8027
+ pcb_smtpad = db.pcb_smtpad.insert({
8028
+ pcb_component_id,
8029
+ pcb_port_id: this.matchedPort?.pcb_port_id,
8030
+ // port likely isn't matched
8031
+ layer: maybeFlipLayer(props.layer ?? "top"),
8032
+ shape: "rotated_pill",
8033
+ x: position.x,
8034
+ y: position.y,
8035
+ radius: props.radius,
8036
+ height: props.height,
8037
+ width: props.width,
8038
+ ccw_rotation: finalRotationDegrees,
8039
+ port_hints: portHints,
8040
+ is_covered_with_solder_mask: isCoveredWithSolderMask,
8041
+ soldermask_margin: soldermaskMargin,
8042
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
8043
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
8044
+ });
8045
+ } else {
8046
+ pcb_smtpad = db.pcb_smtpad.insert({
8047
+ pcb_component_id,
8048
+ pcb_port_id: this.matchedPort?.pcb_port_id,
8049
+ // port likely isn't matched
8050
+ layer: maybeFlipLayer(props.layer ?? "top"),
8051
+ shape: "pill",
8052
+ x: position.x,
8053
+ y: position.y,
8054
+ radius: props.radius,
8055
+ height: props.height,
8056
+ width: props.width,
8057
+ port_hints: portHints,
8058
+ is_covered_with_solder_mask: isCoveredWithSolderMask,
8059
+ soldermask_margin: soldermaskMargin,
8060
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
8061
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
8062
+ });
8063
+ }
7981
8064
  }
7982
8065
  if (pcb_smtpad) {
7983
8066
  this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
@@ -8007,13 +8090,11 @@ var SmtPad = class extends PrimitiveComponent2 {
8007
8090
  };
8008
8091
  }
8009
8092
  if (smtpad.shape === "rotated_rect") {
8010
- const angleRad = smtpad.ccw_rotation * Math.PI / 180;
8011
- const cosAngle = Math.cos(angleRad);
8012
- const sinAngle = Math.sin(angleRad);
8013
- const w2 = smtpad.width / 2;
8014
- const h2 = smtpad.height / 2;
8015
- const xExtent = Math.abs(w2 * cosAngle) + Math.abs(h2 * sinAngle);
8016
- const yExtent = Math.abs(w2 * sinAngle) + Math.abs(h2 * cosAngle);
8093
+ const { width, height, xExtent, yExtent } = getAxisAlignedSizeFromRotatedRect({
8094
+ width: smtpad.width,
8095
+ height: smtpad.height,
8096
+ ccwRotationDegrees: smtpad.ccw_rotation
8097
+ });
8017
8098
  return {
8018
8099
  center: { x: smtpad.x, y: smtpad.y },
8019
8100
  bounds: {
@@ -8022,8 +8103,8 @@ var SmtPad = class extends PrimitiveComponent2 {
8022
8103
  top: smtpad.y - yExtent,
8023
8104
  bottom: smtpad.y + yExtent
8024
8105
  },
8025
- width: xExtent * 2,
8026
- height: yExtent * 2
8106
+ width,
8107
+ height
8027
8108
  };
8028
8109
  }
8029
8110
  if (smtpad.shape === "circle") {
@@ -8074,6 +8155,24 @@ var SmtPad = class extends PrimitiveComponent2 {
8074
8155
  height: smtpad.height
8075
8156
  };
8076
8157
  }
8158
+ if (smtpad.shape === "rotated_pill") {
8159
+ const { width, height, xExtent, yExtent } = getAxisAlignedSizeFromRotatedRect({
8160
+ width: smtpad.width,
8161
+ height: smtpad.height,
8162
+ ccwRotationDegrees: smtpad.ccw_rotation
8163
+ });
8164
+ return {
8165
+ center: { x: smtpad.x, y: smtpad.y },
8166
+ bounds: {
8167
+ left: smtpad.x - xExtent,
8168
+ right: smtpad.x + xExtent,
8169
+ top: smtpad.y - yExtent,
8170
+ bottom: smtpad.y + yExtent
8171
+ },
8172
+ width,
8173
+ height
8174
+ };
8175
+ }
8077
8176
  throw new Error(
8078
8177
  `circuitJson bounds calculation not implemented for shape "${smtpad.shape}"`
8079
8178
  );
@@ -8101,7 +8200,7 @@ var SmtPad = class extends PrimitiveComponent2 {
8101
8200
  const { db } = this.root;
8102
8201
  if (!this.pcb_smtpad_id) return;
8103
8202
  const pad = db.pcb_smtpad.get(this.pcb_smtpad_id);
8104
- if (pad.shape === "rect" || pad.shape === "circle" || pad.shape === "rotated_rect" || pad.shape === "pill") {
8203
+ if (pad.shape === "rect" || pad.shape === "circle" || pad.shape === "rotated_rect" || pad.shape === "pill" || pad.shape === "rotated_pill") {
8105
8204
  this._setPositionFromLayout({ x: pad.x + deltaX, y: pad.y + deltaY });
8106
8205
  } else if (pad.shape === "polygon") {
8107
8206
  db.pcb_smtpad.update(this.pcb_smtpad_id, {
@@ -20024,7 +20123,7 @@ import { identity as identity5 } from "transformation-matrix";
20024
20123
  var package_default = {
20025
20124
  name: "@tscircuit/core",
20026
20125
  type: "module",
20027
- version: "0.0.1192",
20126
+ version: "0.0.1194",
20028
20127
  types: "dist/index.d.ts",
20029
20128
  main: "dist/index.js",
20030
20129
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1193",
4
+ "version": "0.0.1195",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",