@tscircuit/curvy-trace-solver 0.0.1 → 0.0.2

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/README.md +99 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,102 @@
1
1
  # @tscircuit/curvy-trace-solver
2
2
 
3
3
  Convert trace waypoints into curvy traces maximizing trace-to-trace and trace-to-obstacle distance
4
+
5
+ <img width="1352" height="1420" alt="image" src="https://github.com/user-attachments/assets/197d546a-6d2b-4bdc-8708-27a76430ff63" />
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ bun add @tscircuit/curvy-trace-solver
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Basic Example
16
+
17
+ ```typescript
18
+ import { CurvyTraceSolver } from "@tscircuit/curvy-trace-solver"
19
+ import type { CurvyTraceProblem } from "@tscircuit/curvy-trace-solver"
20
+
21
+ const problem: CurvyTraceProblem = {
22
+ bounds: { minX: 0, minY: 0, maxX: 100, maxY: 100 },
23
+ waypointPairs: [
24
+ {
25
+ start: { x: 0, y: 10 },
26
+ end: { x: 100, y: 80 },
27
+ },
28
+ {
29
+ start: { x: 0, y: 20 },
30
+ end: { x: 100, y: 90 },
31
+ },
32
+ ],
33
+ obstacles: [],
34
+ preferredSpacing: 25,
35
+ }
36
+
37
+ const solver = new CurvyTraceSolver(problem)
38
+ solver.solve()
39
+
40
+ // Access the solved traces
41
+ console.log(solver.outputTraces)
42
+ // Each trace contains: { waypointPair, points: Point[], networkId? }
43
+ ```
44
+
45
+ ### Problem Definition
46
+
47
+ A `CurvyTraceProblem` consists of:
48
+
49
+ | Property | Type | Description |
50
+ | ------------------ | ---------------- | --------------------------------------------------------------------------- |
51
+ | `bounds` | `Bounds` | The rectangular area containing the traces (`minX`, `minY`, `maxX`, `maxY`) |
52
+ | `waypointPairs` | `WaypointPair[]` | Array of start/end point pairs to connect with traces |
53
+ | `obstacles` | `Obstacle[]` | Rectangular obstacles that traces should avoid |
54
+ | `preferredSpacing` | `number` | Minimum desired spacing between traces |
55
+
56
+ ### Waypoint Pairs
57
+
58
+ ```typescript
59
+ interface WaypointPair {
60
+ start: { x: number; y: number }
61
+ end: { x: number; y: number }
62
+ networkId?: string // Traces with the same networkId are allowed to intersect
63
+ }
64
+ ```
65
+
66
+ ### Obstacles
67
+
68
+ ```typescript
69
+ interface Obstacle {
70
+ minX: number
71
+ minY: number
72
+ maxX: number
73
+ maxY: number
74
+ center: { x: number; y: number }
75
+ networkId?: string // Traces with matching networkId can pass through this obstacle
76
+ }
77
+ ```
78
+
79
+ ### Output
80
+
81
+ After calling `solver.solve()`, access `solver.outputTraces` which contains:
82
+
83
+ ```typescript
84
+ interface OutputTrace {
85
+ waypointPair: WaypointPair
86
+ points: Point[] // Array of points forming the curved trace
87
+ networkId?: string
88
+ }
89
+ ```
90
+
91
+ ### Visualization
92
+
93
+ The solver provides a `visualize()` method that returns a `GraphicsObject` compatible with `graphics-debug`:
94
+
95
+ ```typescript
96
+ import { getSvgFromGraphicsObject } from "graphics-debug"
97
+
98
+ const solver = new CurvyTraceSolver(problem)
99
+ solver.solve()
100
+
101
+ const svg = getSvgFromGraphicsObject(solver.visualize())
102
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/curvy-trace-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",