fix: preserve normalized colors in PDF output - #1
Merged
Conversation
besmpl
marked this pull request as ready for review
August 10, 2026 17:04
kolkov
approved these changes
Aug 11, 2026
kolkov
left a comment
Contributor
There was a problem hiding this comment.
Good catch — gg.RGBA components are normalized [0, 1], same as creator.Color. The /255.0 division was producing nearly-black colors for everything.
The colorFromGG helper centralizes the conversion nicely, and the opacity fix (br.Color.A instead of br.Color.A / 255.0) is correct.
Tests updated to use gg.RGB() / gg.RGBA2() constructors — much cleaner than the old {R: 255, ...} literals that implied byte-range values.
LGTM, merging.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks
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.
Summary
Root cause
Both
gg.RGBAandcreator.Colordefine color components in the range[0,1]. The backend divided gg components by 255 again, turning ordinary colors almost black and alpha almost transparent.Verification
go test -count=1 ./...go test -race -count=1 ./...go test -count=1 -coverprofile=coverage.out ./...go vet ./...go build ./...go mod tidy -diffgofmtandgit diff --checkThe PDF library's gradient, stroke, and text color APIs are RGB-only, so their pre-existing alpha limitation is unchanged. Solid fill opacity is covered by the regression tests.
Upstream GitHub Actions and
codecov/patchare configured but await maintainer approval of the fork workflow run.