calculate-packing 0.0.75 → 0.0.76

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -102,14 +102,15 @@ var getComponentBounds = (component, minGap = 0) => {
102
102
  };
103
103
  const angleRad = component.ccwRotationOffset * Math.PI / 180;
104
104
  for (const pad of component.pads) {
105
- expandRotatedRectIntoBounds({
106
- bounds,
107
- center: pad.offset,
108
- width: pad.size.x,
109
- height: pad.size.y,
110
- angleRad,
111
- translate: component.center
112
- });
105
+ const rotatedOffset = rotatePoint(pad.offset, angleRad);
106
+ const cx = component.center.x + rotatedOffset.x;
107
+ const cy = component.center.y + rotatedOffset.y;
108
+ const hw = pad.size.x / 2;
109
+ const hh = pad.size.y / 2;
110
+ bounds.minX = Math.min(bounds.minX, cx - hw);
111
+ bounds.maxX = Math.max(bounds.maxX, cx + hw);
112
+ bounds.minY = Math.min(bounds.minY, cy - hh);
113
+ bounds.maxY = Math.max(bounds.maxY, cy + hh);
113
114
  }
114
115
  if (component.courtyard) {
115
116
  expandRotatedRectIntoBounds({
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "calculate-packing",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.75",
5
+ "version": "0.0.76",
6
6
  "description": "Calculate a packing layout with support for different strategy configurations",
7
7
  "scripts": {
8
8
  "start": "cosmos",