Repository navigation
Conversation
…cursor at non-100% display scaling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5
Problem
At any display scaling other than 100% (e.g. Windows 125%/150%, or browser zoom), strokes and shapes drawn with the Chrome extension land offset from the cursor. The offset grows with distance from the top-left corner. The web app is unaffected.
Root cause
The drawing canvas in
apps/extension/components/Canvas.tsxis styledfixed inset-0, and its backing buffer is sized toinnerWidth * devicePixelRatiowith a DPR transform on the context. A<canvas>is a replaced element, soinset: 0doesn't stretch it: withwidth: autoit renders at its intrinsic size, which is the DPR-scaled buffer. The canvas ends updevicePixelRatio× larger than the viewport, and every stroke is magnified by that factor from the origin.At 100% scaling DPR is 1, so the bug never showed up there.
Fix
Give the canvas an explicit size so its CSS box always matches the viewport:
AreaMarkup.tsxalready sets explicit CSSwidth/heighton its canvas, so it needs no change.Testing
Built the extension and loaded it in Chromium with
--force-device-scale-factor, then dragged a rectangle from (200,200) to (400,300) CSS px and measured the drawn bounds on the canvas: