Skip to content

Choose a file format and background when creating a document - #15

Merged
dariomory merged 1 commit into
masterfrom
fix/1-new-document-format
Sep 3, 2026
Merged

dariomory merged 1 commit into
masterfrom
fix/1-new-document-format

Conversation

@dariomory

Copy link
Copy Markdown
Member

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.

New document dialog with Format and Background selects

New
  Width       1920
  Height      1080
  Format      [PNG  v]
  Background  [White v]

Two supporting changes

Transparency now survives export. flattenDocumentToCanvas unconditionally 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. seedBlankDocument keeps 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.

initial:     format=png   background opts: transparent, white, black
after jpeg:  format=jpeg  background opts: transparent(disabled), white, black
layers after create: 1

pnpm test (21) and pnpm exec tsc --noEmit are clean.

Branched off master and independent of #13 and #14, so all three can merge in any order.

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
@dariomory
dariomory merged commit 89f7a69 into master Sep 3, 2026
1 check passed
@dariomory
dariomory deleted the fix/1-new-document-format branch September 3, 2026 09:31
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.

feat: allow selecting file format when creating files

1 participant