Skip to content

Conversation

ganomi
Copy link
Contributor

@ganomi ganomi commented Sep 15, 2025

Hi @rototor

i had some time to look into #60 and i am proposing two small changes in this pull request.

First change is the exception fix:
The root cause for this issue is the edge case where a transparent gradient has missing keyframes at the beginning AND at the end at the same time. In this case the reuse of the previous alpha for the last fraction was not implemented.

When fixing this, i also created a bunch of syntetic visual tests to make sure i am not breaking anything.
When comparing the pdf output to svg renderings i realized that there is a small difference when an artificial keyframe is inserted at the start and the first stop defines opacity. Therefore i propose my second change:

Second change is the reuse of alpha for the first keyframe instead of using stop-opacity default value 1f.
A gradient (in color and opacity) should only be visible between two explicit stops, not between the start and first stop of a gradient or the last stop and the end of the gradient. So the implemented behavior is now similar to the implementation for the end of the gradient.

…or the first fraction and for the last fraction at the same time. Fixed by using the same approach as if there was only an artificial key frame for the last fraction, which reuses the alpha of the last color.

Adjustment for the starting alpha of an artificial key frame for the first fraction. Gradients should only be visible between two stop elements, not between start and stop or stop and end. To achieve this, the alpha needs to be the same for start and first stop.
@ganomi ganomi changed the base branch from master to pdfbox-3.0.0 September 15, 2025 11:10
@ganomi ganomi changed the base branch from pdfbox-3.0.0 to master September 15, 2025 14:03
@rototor
Copy link
Owner

rototor commented Sep 22, 2025

Thanks a lot for this PR. Sorry for the late response, I'm currently rather busy :-(

The PR seems fine, but I would like to test it myself before merging. I'll try to schedule that sometime on next Saturday... Hopefully I find time there...

@rototor
Copy link
Owner

rototor commented Sep 27, 2025

Your PR does not fully fix the issue with some grandients on the tux.png, but it got a bit better:

image Left being the PDF rendering the other being a PNG rendering. I think the remaining issue has something to do with transformation matrixes...

But thank you very much for this PR!

@rototor rototor merged commit eebb57f into rototor:master Sep 27, 2025
4 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