Repository navigation
Choose a file format and background when creating a document - #15
Merged
Merged
Conversation
The New dialog offered only width and height, and every document saved as PNG regardless. Documents now carry a format, chosen at creation from PNG, JPEG or WebP, and Save As proposes that extension. The background can be Transparent, White or Black; picking JPEG disables Transparent and explains why, since JPEG has no alpha channel. Two supporting changes fell out of that. Flattening no longer paints a background when its alpha is zero, so transparency survives export, and composites onto white only when the target format cannot carry alpha. And a document created deliberately no longer gets the decorative sample overlay - that belongs to the document seeded at startup, and on a transparent canvas it just looks like debris. Fixes #1
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 #1
The New dialog offered width and height and nothing else, and every document saved as PNG regardless of what you wanted.
What changed
Documents now carry a
format— PNG, JPEG or WebP — chosen when the document is created, and Save As proposes the matching extension. The background is selectable too: Transparent, White or Black.Picking JPEG disables Transparent and says why, since JPEG has no alpha channel.
Two supporting changes
Transparency now survives export.
flattenDocumentToCanvasunconditionally painted the background colour, so a transparent document could never produce a transparent PNG. It now skips the fill when the background alpha is zero, and composites onto white only when the target format cannot carry alpha.A deliberately created document no longer gets the sample overlay. That decorative golden circle belongs to the document seeded at startup. On a transparent canvas it reads as debris, and on any new document it is something to delete before starting.
seedBlankDocumentkeeps it for the startup document only.Verification
Driven in a browser: the dialog exposes both selects; selecting JPEG marks the Transparent option
disabled; creating with Transparent produces a single Background layer rather than two.pnpm test(21) andpnpm exec tsc --noEmitare clean.Branched off
masterand independent of #13 and #14, so all three can merge in any order.