@tscircuit/matchpack 0.0.20 → 0.0.21

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
@@ -244,6 +244,8 @@ declare class PartitionPackingSolver extends BaseSolver {
244
244
  private organizePackedPartitions;
245
245
  private createPackInput;
246
246
  private applyPackingResult;
247
+ private getCombinedPackedPartitionsProblem;
248
+ private getCombinedPackedPartitionsLayout;
247
249
  visualize(): GraphicsObject;
248
250
  getConstructorParams(): PartitionPackingSolverInput;
249
251
  }
package/dist/index.js CHANGED
@@ -99,8 +99,14 @@ function getChipLabelFontSize(width, height) {
99
99
  const smallerDimension = Math.min(width, height);
100
100
  return Math.min(0.35, Math.max(0.08, smallerDimension * 0.22));
101
101
  }
102
- function getChipFillColor(chipId) {
102
+ function getChipFillColor(chipId, isFixed = false) {
103
103
  const chipType = chipId.charAt(0).toUpperCase();
104
+ if (isFixed) {
105
+ if (chipType === "C") return "rgba(30, 64, 175, 0.35)";
106
+ if (chipType === "R") return "rgba(5, 150, 105, 0.35)";
107
+ if (chipType === "L") return "rgba(126, 34, 206, 0.35)";
108
+ if (chipType === "U") return "rgba(180, 83, 9, 0.35)";
109
+ }
104
110
  if (chipType === "C") return "rgba(59, 130, 246, 0.18)";
105
111
  if (chipType === "R") return "rgba(16, 185, 129, 0.18)";
106
112
  if (chipType === "L") return "rgba(168, 85, 247, 0.18)";
@@ -146,18 +152,19 @@ function visualizeInputProblem(inputProblem, basicLayout) {
146
152
  height,
147
153
  placement.ccwRotationDegrees
148
154
  );
155
+ const chipLabel = chip.fixedPosition ? `${chipId} [fixed]` : chipId;
149
156
  inputViz.rects.push({
150
157
  center: { x: chipCenterX, y: chipCenterY },
151
158
  width: rotatedDims.width,
152
159
  height: rotatedDims.height,
153
- label: chipId,
154
- fill: getChipFillColor(chipId),
160
+ label: chipLabel,
161
+ fill: getChipFillColor(chipId, Boolean(chip.fixedPosition)),
155
162
  stroke: "none"
156
163
  });
157
164
  inputViz.texts.push({
158
165
  x: chipCenterX,
159
166
  y: chipCenterY,
160
- text: chipId,
167
+ text: chipLabel,
161
168
  fontSize: getChipLabelFontSize(rotatedDims.width, rotatedDims.height)
162
169
  });
163
170
  for (const pin of chipPins) {
@@ -303,9 +310,16 @@ function doBasicInputProblemLayout(inputProblem) {
303
310
  offset: { x: 0, y: 0 },
304
311
  size: { x: chip.size.x, y: chip.size.y }
305
312
  });
313
+ const fixedRotation = chip.availableRotations?.[0] ?? 0;
306
314
  return {
307
315
  componentId: chipId,
308
- pads
316
+ pads,
317
+ availableRotationDegrees: chip.availableRotations ?? [0, 90, 180, 270],
318
+ ...chip.fixedPosition && {
319
+ isStatic: true,
320
+ center: chip.fixedPosition,
321
+ ccwRotationOffset: fixedRotation
322
+ }
309
323
  };
310
324
  }
311
325
  );
@@ -508,7 +522,8 @@ var ChipPartitionsSolver = class extends BaseSolver {
508
522
  }
509
523
  visualize() {
510
524
  if (this.partitions.length === 0) {
511
- return super.visualize();
525
+ const layout = doBasicInputProblemLayout(this.inputProblem);
526
+ return visualizeInputProblem(this.inputProblem, layout);
512
527
  }
513
528
  const partitionVisualizations = this.partitions.map((partition) => {
514
529
  const layout = doBasicInputProblemLayout(partition);
@@ -1003,7 +1018,12 @@ var PackInnerPartitionsSolver = class extends BaseSolver {
1003
1018
  return this.activeSolver.visualize();
1004
1019
  }
1005
1020
  if (this.completedSolvers.length === 0) {
1006
- return super.visualize();
1021
+ const partitionVisualizations2 = this.partitions.map((partition) => {
1022
+ const layout = doBasicInputProblemLayout(partition);
1023
+ return visualizeInputProblem(partition, layout);
1024
+ });
1025
+ const titles2 = this.partitions.map((_, index) => `partition${index}`);
1026
+ return stackGraphicsHorizontally2(partitionVisualizations2, { titles: titles2 });
1007
1027
  }
1008
1028
  const partitionVisualizations = this.completedSolvers.map(
1009
1029
  (solver) => solver.visualize()
@@ -1245,13 +1265,7 @@ var PartitionPackingSolver = class extends BaseSolver {
1245
1265
  groupPlacements: {}
1246
1266
  };
1247
1267
  }
1248
- visualize() {
1249
- if (this.packSolver2 && !this.solved) {
1250
- return this.packSolver2.visualize();
1251
- }
1252
- if (!this.finalLayout) {
1253
- return super.visualize();
1254
- }
1268
+ getCombinedPackedPartitionsProblem() {
1255
1269
  const combinedProblem = {
1256
1270
  chipMap: {},
1257
1271
  chipPinMap: {},
@@ -1280,7 +1294,35 @@ var PartitionPackingSolver = class extends BaseSolver {
1280
1294
  packedPartition.inputProblem.netConnMap
1281
1295
  );
1282
1296
  }
1283
- return visualizeInputProblem(combinedProblem, this.finalLayout);
1297
+ return combinedProblem;
1298
+ }
1299
+ getCombinedPackedPartitionsLayout() {
1300
+ const chipPlacements = {};
1301
+ for (const packedPartition of this.packedPartitions) {
1302
+ Object.assign(chipPlacements, packedPartition.layout.chipPlacements);
1303
+ }
1304
+ return {
1305
+ chipPlacements,
1306
+ groupPlacements: {}
1307
+ };
1308
+ }
1309
+ visualize() {
1310
+ if (this.packSolver2 && !this.solved) {
1311
+ return this.packSolver2.visualize();
1312
+ }
1313
+ if (!this.finalLayout) {
1314
+ if (this.packedPartitions.length === 0) {
1315
+ return super.visualize();
1316
+ }
1317
+ return visualizeInputProblem(
1318
+ this.getCombinedPackedPartitionsProblem(),
1319
+ this.getCombinedPackedPartitionsLayout()
1320
+ );
1321
+ }
1322
+ return visualizeInputProblem(
1323
+ this.getCombinedPackedPartitionsProblem(),
1324
+ this.finalLayout
1325
+ );
1284
1326
  }
1285
1327
  getConstructorParams() {
1286
1328
  return {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/matchpack",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.20",
5
+ "version": "0.0.21",
6
6
  "files": [
7
7
  "dist"
8
8
  ],