Skip to content

Z fits a part as it is drawn, turned by its angle and the board (#142) - #143

Merged
Gherkin merged 1 commit into
mainfrom
z-fits-turned-part-142
Oct 27, 2026
Merged

Gherkin merged 1 commit into
mainfrom
z-fits-turned-part-142

Conversation

@Gherkin

@Gherkin Gherkin commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Closes #142.

zoomToFootprint now calls zoomFitPoints with footprintCorners(fp). The fit then uses the part's box as it is drawn: turned by the part's angle and by the board rotation. The centre is also right now. The old code took the centre from the unturned box.

The copy of the fit math in zoomToFootprint is gone. A single part now gets the same zoom limit as E: 200 instead of 50.

Tests

fit.spec.js gets four Z tests: a part turned 90° and an unturned long part, each with the board at 0° and 90°. Each checks that the view holds the part with the 8 mm margin, is tight on one axis, and is centred on the part.

With the old code, three of the four fail:

  • turned part, board 0°: view 9.5% too loose (width and height swapped)
  • unturned part, board 90°: view 17.95 high, needs 19.29 (part is cut off)
  • turned part, board 90°: the two turns cancel, but the centre is 0.01 off

Full browser suite: 150 passed. The one failure was the known flaky timeout in interaction.spec.js ("an inner layer checkbox changes both sides"). It passed when run alone. npm run test:api passes.

Not checked in a real browser by hand.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-27 20:02 UTC

@Gherkin

Gherkin commented Oct 27, 2026

Copy link
Copy Markdown
Owner Author

Review round 1.

No correctness findings. zoomToFootprint now goes through zoomFitPoints + footprintCorners, the same path E uses for pinned parts. The early return when the canvas is missing is kept. CI is green.

Open decision:

  • web/render.js:1403: a single part now gets zoom limit 200 (was 50). Z fits a turned part with width and height swapped #142 left this choice open. In practice neither limit is hit: the 8 mm margin makes the fit box at least 16 mm, so zoom stays near board size / 16. The limit only matters on a board around 800 mm across.

FYI:

  • tests/browser/fit.spec.js:151: the Z tests cover only side F. B goes through the same zoomFitPoints flip branch that a B-side E test (fit.spec.js:113) already runs, so I did not add tests.

@Gherkin
Gherkin merged commit db88df4 into main Oct 27, 2026
10 checks passed
@Gherkin
Gherkin deleted the z-fits-turned-part-142 branch October 27, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Z fits a turned part with width and height swapped

1 participant