Repository navigation
feat: export at the resolution of the background image, and restore the size of the canvas - #216
Merged
Merged
Conversation
…he size of the canvas
toDataURL({ multiplier: "original" }) draws the drawing with one pixel of the
picture for each pixel of the background image, at any size of the canvas, so a
drawing on a photo does not lose the resolution of the photo. getOriginalSize()
returns the size of that image, and the showcase has an Original size button
which gives the canvas that size, and downloads at that resolution.
The factors which scale the drawing when the canvas is resized were rounded to
two decimals, so the drawing was a little off its size, the error added up with
every resize, and a canvas could not go back to the size it had. They are exact
now.
tbolis
commented
Nov 10, 2026
tbolis
commented
Nov 10, 2026
Remove the comment above the resize factors, and replace the HTML table of the options in the documentation of toDataURL with a reference to DataUrlOptions, which describes each of them.
…inal-resolution # Conflicts: # CHANGELOG.md
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.
Refs #75 (not closed by this: the issue can be answered once it is released).
Problem
The canvas has the size of its container, and
toDataURL()draws at that size. A photo which is shown smaller than it is loses pixels in the exported file, and drawing on an exported image again loses more each time.Changes
toDataURL({ multiplier: "original" }): one pixel of the picture for each pixel of the background image, at any size of the canvas. It is 1 without a background image. An image scaled differently in the two directions is exported at the larger scale, so no pixel of it is lost.getOriginalSize(): the size of the background image in pixels, or undefined without one (or while it loads). New typeTypes.SketchSize.autoresizerounded its scale factors to two decimals, so the drawing and the background image were a little off their size, the error added up with every resize, and a canvas could not go back to the size it had. The factors are exact now. This changes an existing behavior, so it is in the CHANGELOG under Fixed.Verification
SketchField.spec.tsx: the multiplier (scaled, zoomed, smaller than the canvas, different scales in the two directions, flipped, no image, other options kept),getOriginalSize(), and the resize (several sizes and back, the size of the image throughlayoutand through thewidthandheightproperties). The two resize tests fail with the rounding put back.yarn buildpass.Notes
## 1.2.0heading toCHANGELOG.md, and feat: add the bucket fill tool #214 changes showcase files, so the second and third to merge need a conflict resolution.