Skip to content

fix(ruler): round display mm on rotated labels to drop float noise#45

Merged
u8array merged 1 commit into
mainfrom
fix/ruler-label-rounding
May 10, 2026
Merged

fix(ruler): round display mm on rotated labels to drop float noise#45
u8array merged 1 commit into
mainfrom
fix/ruler-label-rounding

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 10, 2026

When the ruler is reversed for 180°/270° rotated labels, computing labelXxxMm - mm reintroduces IEEE-754 artefacts (e.g. 100 - 30 = 70.00000000000001) on top of the already-rounded mm. The result rendered as tick labels with up to 12 trailing decimals.

Re-round at the subtraction site, mirroring the existing rounding on the mm accumulator. rulerLabel stays a neutral formatter.

When the ruler is reversed for 180°/270° rotated labels, computing
`labelXxxMm - mm` reintroduces IEEE-754 artefacts (e.g. 100 - 30 =
70.00000000000001) on top of the already-rounded `mm`. The result
rendered as tick labels with up to 12 trailing decimals.

Re-round at the subtraction site, mirroring the existing rounding on
the `mm` accumulator. `rulerLabel` stays a neutral formatter.
@u8array u8array merged commit daf2302 into main May 10, 2026
2 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses floating-point precision issues in the Ruler component by rounding tick label values to three decimal places when the ruler is reversed. This prevents IEEE-754 artifacts from creating visual noise in the labels. The review feedback suggests duplicating the explanatory comment from the horizontal ruler implementation to the vertical ruler for better consistency and maintainability.

Comment thread src/components/Canvas/Ruler.tsx
@u8array u8array deleted the fix/ruler-label-rounding branch May 10, 2026 20:06
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.

1 participant