Skip to content

Expose cairo antialiasing abilities #8784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anntzer opened this issue Jun 20, 2017 · 2 comments
Closed

Expose cairo antialiasing abilities #8784

anntzer opened this issue Jun 20, 2017 · 2 comments

Comments

@anntzer
Copy link
Contributor

anntzer commented Jun 20, 2017

Currently, the cairo backend does not support setting antialiasing:

    #def set_antialiased(self, b):
        # enable/disable anti-aliasing is not (yet) supported by Cairo

This comment is no longer true; in fact many antialiasing modes have been supported for a while (and can be easily set):
https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-set-antialias
https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t

The issue is that True/False is not sufficient to describe the antialiasing modes. Should we, say, allow the user to pass in a string value ("default"/"none"/"gray"/etc.)? Passing a "native" cairo value won't work, as they are simply integers (and exposed as such by cairocffi, and as int subclasses by pycairo), and ANTIALIAS_DEFAULT=0 (which includes some antialiasing) and ANTIALIAS_NONE=1, which will conflict with the integer values of False=0, True=1.

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 13, 2023
@anntzer
Copy link
Contributor Author

anntzer commented Apr 13, 2023

This has been partially implemented in #19719, but it is still not possible to specifically pick detailed cairo antialias values ("default"/"none"/"gray"/etc.) I now think that extra degree of customization is better handled on backend_cairo's side by providing e.g. backend_cairo.set_antialias("default", text="best") to mean "antialias=True means ANTIALIAS_DEFAULT, except for texts which use ANTIALIAS_BEST" (texts go through a separate path for antialiasing so it is reasonable to provide a separate configuration knob specifically for them). This seems simpler than forcing all artists to carry detailed antialiasing state which only matters for some backends; also note that while not impossible, the use case of wanting some artists to use ANTIALIAS_FAST and others to use ANTIALIAS_BEST seems rare.

I'll make a PR for backend_cairo, with the idea of implementing the same API in mplcairo; I think it's still useful to have that in backend_cairo as an "official" example of how to configure this kind of extra abilities in third-party backends.


Edit: I changed my mind; let's just close this. Indeed, the natural way to store this for the cairo backend would be in rcparams (after all there are already webagg-specific rcparams too), but it would be awkward if those didn't apply to mplcairo. However mplcairo currently uses more complex defaults (currently it defaults to ANTIALIAS_FAST except for very thin lines for which it uses ANTIALIAS_BEST, which is a choice I've made basically on aesthetical grounds) but I don't want to leak these details back into matplotlib itself... In any case, real-world demand for this seems nonexistent; we can always revisit as needed.

@anntzer anntzer removed the status: inactive Marked by the “Stale” Github Action label Apr 13, 2023
@anntzer anntzer closed this as completed Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant