Repository navigation
Conversation
This branch has not been deployed
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.
PR summary
This PR adds two new blend modes, which provide alternatives when alpha values represent pixel coverage rather than opacity. These blend modes are supported by only the Agg backend (and vector backends through rasterization).
Alpha is the combination of both opacity (i.e., transparency) and pixel coverage (the fraction of the pixel that is filled in with a color). In matplotlib, the alpha values along antialiased edges of patches is determined by calculating the pixel coverage. Importantly, once the alpha for a pixel is represented as a single number, there is no longer any geometric information about which part of the pixel is actually covered.
When alpha represents opacity, the existing blend modes have the desired output. When alpha represents pixel coverage, the behavior of the PDF blend modes is equivalent to assuming that the part of the source pixel that is covered and the part of the destination pixel that is covered are unrelated/independent. However, that assumption is broken when two patches intentionally share an edge:
src.alpha + dest.alpha == 1), ideally the result pixel would have an alpha of 1. However, the assumption that the pixel coverages are independent means that the combined alpha is less than 1 (out.alpha = src.alpha + dest.alpha - src.alpha * dest.alpha < 1).The two new blend modes in this PR are:
src.alpha + dest.alpha <= 1, but it favors the source color whensrc.alpha + dest.alpha > 1.src.alpha >= dest.alphain that the source completely hides the destination.This PR is an outgrowth of #32256, which currently uses the "plus" blend mode, but would behave better with the "min cover" blend mode in those situations when a collection of contiguous patches can also have overlapping of patches (e.g., as a result of a projection down from 3D space).
Example
AI Disclosure
No AI was used
PR quality check