Skip to content

fix: correct PDF y-axis transform - #2

Merged
kolkov merged 1 commit into
gogpu:mainfrom
besmpl:agent/fix-pdf-y-axis
Aug 11, 2026
Merged

fix: correct PDF y-axis transform#2
kolkov merged 1 commit into
gogpu:mainfrom
besmpl:agent/fix-pdf-y-axis

Conversation

@besmpl

@besmpl besmpl commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • compose the PDF page transform in scale-then-translate order
  • apply the same top-left-to-bottom-left mapping in Backend.Begin and Document.NewPage
  • add regressions that assert the exact composed transform implementing (0, 0) → (0, height) and (0, height) → (0, 0)

Why

Transform.Then applies the receiver before the next transform. Translating before the negative Y scale produced y' = -height - y, placing gg coordinates below the page. Scaling first and translating second produces the intended y' = height - y.

Verification

  • go test ./... -count=1
  • go test -race ./... -count=1
  • go build ./...
  • go vet ./...
  • gofmt and git diff --check
  • local added executable-line patch coverage: 100% (2/2)

Upstream GitHub Actions and codecov/patch are configured but await maintainer approval of the fork workflow run.

@kolkov kolkov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct fix. Transform.Then applies the receiver first, so Translate(0, h).Then(Scale(1, -1)) was producing y' = -(y + h) instead of the intended y' = h - y. Scale(1, -1).Then(Translate(0, h)) gives the right top-left → bottom-left mapping.

Both Backend.Begin and Document.NewPage fixed consistently. Tests assert the exact composed transform — good regression coverage.

LGTM, merging.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@kolkov
kolkov merged commit 06a9675 into gogpu:main Aug 11, 2026
10 checks passed
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.

2 participants