Fixing out of bounds exception on transparent gradient when keyframes are missing on both ends #64
+279
−5
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.
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.