@tscircuit/matchpack 0.0.18 → 0.0.20

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 +21 -2
  2. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -95,6 +95,18 @@ function getRotatedDimensions(width, height, rotation) {
95
95
  }
96
96
  return { width, height };
97
97
  }
98
+ function getChipLabelFontSize(width, height) {
99
+ const smallerDimension = Math.min(width, height);
100
+ return Math.min(0.35, Math.max(0.08, smallerDimension * 0.22));
101
+ }
102
+ function getChipFillColor(chipId) {
103
+ const chipType = chipId.charAt(0).toUpperCase();
104
+ if (chipType === "C") return "rgba(59, 130, 246, 0.18)";
105
+ if (chipType === "R") return "rgba(16, 185, 129, 0.18)";
106
+ if (chipType === "L") return "rgba(168, 85, 247, 0.18)";
107
+ if (chipType === "U") return "rgba(245, 158, 11, 0.18)";
108
+ return "rgba(59, 130, 246, 0.12)";
109
+ }
98
110
  function visualizeInputProblem(inputProblem, basicLayout) {
99
111
  const inputViz = {
100
112
  points: [],
@@ -138,9 +150,16 @@ function visualizeInputProblem(inputProblem, basicLayout) {
138
150
  center: { x: chipCenterX, y: chipCenterY },
139
151
  width: rotatedDims.width,
140
152
  height: rotatedDims.height,
141
- label: chipId
153
+ label: chipId,
154
+ fill: getChipFillColor(chipId),
155
+ stroke: "none"
156
+ });
157
+ inputViz.texts.push({
158
+ x: chipCenterX,
159
+ y: chipCenterY,
160
+ text: chipId,
161
+ fontSize: getChipLabelFontSize(rotatedDims.width, rotatedDims.height)
142
162
  });
143
- inputViz.texts.push({ x: chipCenterX, y: chipCenterY, text: chipId });
144
163
  for (const pin of chipPins) {
145
164
  const rotatedOffset = rotatePoint(
146
165
  pin.offset,
package/package.json CHANGED
@@ -2,12 +2,13 @@
2
2
  "name": "@tscircuit/matchpack",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.18",
5
+ "version": "0.0.20",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
9
9
  "scripts": {
10
10
  "start": "cosmos",
11
+ "test": "bun test",
11
12
  "build": "tsup-node --format esm --dts --clean ./lib/index.ts",
12
13
  "format": "biome format --write .",
13
14
  "format:check": "biome format .",
@@ -20,6 +21,7 @@
20
21
  "@tscircuit/math-utils": "^0.0.36",
21
22
  "@tscircuit/schematic-viewer": "^2.0.61",
22
23
  "@types/bun": "^1.3.14",
24
+ "bun-match-svg": "^0.0.15",
23
25
  "bpc-graph": "^0.0.66",
24
26
  "calculate-packing": "^0.0.74",
25
27
  "circuit-json": "^0.0.432",