@tscircuit/rectdiff 0.0.6 → 0.0.8

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.
@@ -0,0 +1,59 @@
1
+ <svg width="640" height="640" viewBox="0 0 640 640" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="white"/><g><polyline data-points="-8,-6 -2,-6 -2,2 2,2 2,-6 8,-6 8,6 -8,6 -8,-6" data-type="line" data-label="outline" points="40,530 250,530 250,250.00000000000006 390,250.00000000000006 390,530 600,530 600,110.00000000000006 40,110.00000000000006 40,530" fill="none" stroke="#111827" stroke-width="0.35000000000000003"/></g><g><rect data-type="rect" data-label="obstacle" data-x="-5.51" data-y="-4" x="117.70000000000002" y="448.80000000000007" width="18.899999999999977" height="22.399999999999977" fill="#fee2e2" stroke="#ef4444" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="obstacle" data-x="-4.49" data-y="-4" x="153.4" y="448.80000000000007" width="18.899999999999977" height="22.399999999999977" fill="#fee2e2" stroke="#ef4444" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="obstacle" data-x="4.49" data-y="-4" x="467.70000000000005" y="448.80000000000007" width="18.899999999999977" height="22.399999999999977" fill="#fee2e2" stroke="#ef4444" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="obstacle" data-x="5.51" data-y="-4" x="503.4" y="448.80000000000007" width="18.899999999999977" height="22.399999999999977" fill="#fee2e2" stroke="#ef4444" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="void" data-x="0" data-y="-2" x="250" y="250.00000000000006" width="140" height="279.99999999999994" fill="rgba(0, 0, 0, 0.5)" stroke="none" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
2
+ z:0,1" data-x="-5" data-y="1.1600000000000006" x="40" y="110" width="210" height="338.80000000000007" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
3
+ z:0,1" data-x="5" data-y="1.1600000000000006" x="390" y="110" width="210" height="338.80000000000007" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
4
+ z:0,1" data-x="0" data-y="4" x="250" y="110.00000000000006" width="140" height="140" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
5
+ z:0,1" data-x="-5.48" data-y="-5.16" x="40" y="471.20000000000005" width="176.39999999999998" height="58.799999999999955" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
6
+ z:0,1" data-x="5.48" data-y="-5.16" x="423.6" y="471.20000000000005" width="176.39999999999998" height="58.799999999999955" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
7
+ z:0,1" data-x="-2.4800000000000004" data-y="-4.84" x="216.39999999999998" y="448.80000000000007" width="33.60000000000002" height="81.19999999999993" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
8
+ z:0,1" data-x="2.4800000000000004" data-y="-4.84" x="390" y="448.80000000000007" width="33.60000000000002" height="81.19999999999993" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
9
+ z:1" data-x="-5.48" data-y="-4" x="40" y="448.80000000000007" width="176.39999999999998" height="22.399999999999977" fill="#fef3c7" stroke="#f59e0b" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
10
+ z:1" data-x="5.48" data-y="-4" x="423.6" y="448.80000000000007" width="176.39999999999998" height="22.399999999999977" fill="#fef3c7" stroke="#f59e0b" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
11
+ z:0" data-x="6.890000000000001" data-y="-4" x="522.3" y="448.80000000000007" width="77.70000000000005" height="22.399999999999977" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
12
+ z:0" data-x="-6.89" data-y="-4" x="40" y="448.80000000000007" width="77.70000000000002" height="22.399999999999977" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
13
+ z:0" data-x="-5" data-y="-4" x="136.6" y="448.80000000000007" width="16.80000000000001" height="22.399999999999977" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
14
+ z:0" data-x="-3.5900000000000003" data-y="-4" x="172.3" y="448.80000000000007" width="44.099999999999966" height="22.399999999999977" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
15
+ z:0" data-x="3.5900000000000007" data-y="-4" x="423.6" y="448.80000000000007" width="44.10000000000002" height="22.399999999999977" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g><rect data-type="rect" data-label="free
16
+ z:0" data-x="5" data-y="-4" x="486.6" y="448.80000000000007" width="16.799999999999955" height="22.399999999999977" fill="#dbeafe" stroke="#3b82f6" stroke-width="0.02857142857142857"/></g><g id="crosshair" style="display: none"><line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5"/><line id="crosshair-v" x1="0" x2="640" stroke="#666" stroke-width="0.5"/><text id="coordinates" font-family="monospace" font-size="12" fill="#666"></text></g><script><![CDATA[
17
+ document.currentScript.parentElement.addEventListener('mousemove', (e) => {
18
+ const svg = e.currentTarget;
19
+ const rect = svg.getBoundingClientRect();
20
+ const x = e.clientX - rect.left;
21
+ const y = e.clientY - rect.top;
22
+ const crosshair = svg.getElementById('crosshair');
23
+ const h = svg.getElementById('crosshair-h');
24
+ const v = svg.getElementById('crosshair-v');
25
+ const coords = svg.getElementById('coordinates');
26
+
27
+ crosshair.style.display = 'block';
28
+ h.setAttribute('x1', '0');
29
+ h.setAttribute('x2', '640');
30
+ h.setAttribute('y1', y);
31
+ h.setAttribute('y2', y);
32
+ v.setAttribute('x1', x);
33
+ v.setAttribute('x2', x);
34
+ v.setAttribute('y1', '0');
35
+ v.setAttribute('y2', '640');
36
+
37
+ // Calculate real coordinates using inverse transformation
38
+ const matrix = {"a":35,"c":0,"e":320,"b":0,"d":-35,"f":320.00000000000006};
39
+ // Manually invert and apply the affine transform
40
+ // Since we only use translate and scale, we can directly compute:
41
+ // x' = (x - tx) / sx
42
+ // y' = (y - ty) / sy
43
+ const sx = matrix.a;
44
+ const sy = matrix.d;
45
+ const tx = matrix.e;
46
+ const ty = matrix.f;
47
+ const realPoint = {
48
+ x: (x - tx) / sx,
49
+ y: (y - ty) / sy // Flip y back since we used negative scale
50
+ }
51
+
52
+ coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
53
+ coords.setAttribute('x', (x + 5).toString());
54
+ coords.setAttribute('y', (y - 5).toString());
55
+ });
56
+ document.currentScript.parentElement.addEventListener('mouseleave', () => {
57
+ document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
58
+ });
59
+ ]]></script></svg>
@@ -0,0 +1,18 @@
1
+ import { expect, test } from "bun:test"
2
+ import boardWithCutout from "../test-assets/board-with-cutout.json"
3
+ import { RectDiffSolver } from "../lib/solvers/RectDiffSolver"
4
+ import { getSvgFromGraphicsObject } from "graphics-debug"
5
+
6
+ test("board outline snapshot", async () => {
7
+ const solver = new RectDiffSolver({
8
+ simpleRouteJson: boardWithCutout as any,
9
+ })
10
+
11
+ // Run to completion
12
+ solver.solve()
13
+
14
+ const viz = solver.visualize()
15
+ const svg = getSvgFromGraphicsObject(viz)
16
+
17
+ await expect(svg).toMatchSvgSnapshot(import.meta.path)
18
+ })