-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Rastized background color #2479
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
Conversation
The change to the agg propagate to how `imsave` works so one test had to be changed to account for the fact that pixels with alpha=0 are now set to (1, 1, 1, 0) instead of (0, 0, 0, 0).
This seems like a reasonable solution, given that we can't do alpha blending in postscript anyway. I wonder if there's a way to pass down the actual axes fill color and use that, though. We should also update the |
color to use in `clear` calls to the render_base. Changed all uses of `clear((...))` -> `clear(_fil_color)`.
Added a class variable so that the value isn't as hard coded. I didn't add a setter function because that seems like an API change to me which should go onto master once this is merged into 1.3.x and 1.3.x is merged into master. |
I am confused by what travis is doing here. It complies fine on my box, but travis complains that the new class member does not exist in the scope. |
on travis will not.
That's definitely better. But what I was getting at is that the axes background can be changed by the user, and maybe we should use that value. I think the easiest way is to probably add an optional argument to "clear" to pass in a color, and have the code that draws the quadmesh call clear explicitly first. |
Do you want that added to this PR or a separate PR against master? |
Ideally added to this PR -- I think it all fits under the category of bugfix. But if it looks too convoluted to solve that way, I think this PR is an obvious improvement over the current state of affairs. |
Sorry for going quiet. I am entering the home stretch of my PhD (defense is scheduled for December). I needed this fixed for some of my figures, but I don't want to commit to adding much else. |
@@ -421,7 +421,8 @@ | |||
rendererAA(), | |||
rendererBin(), | |||
theRasterizer(), | |||
debug(debug) | |||
debug(debug), | |||
_fill_color(agg::rgba(1, 1, 1, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this value changed from (0, 0, 0, 0)
to (1, 1, 1, 0)
? This was a change I introduced in d8fce7b which I'm surprised is not triggering some of the tests I added to fail. Would you mind providing some more detail in the description of the PR please?
I'd like to put the brakes on this PR as I have a few concerns, mainly with regards to the modification of expected behaviour (the test which was changed). I think we need some more detail as to the motivation for the change (please update the description of the PR) - only then is it feasible to agree on wether this is a bug fix, or a feature enhancement, and indeed whether this change is desirable. Right now I'm undecided and very much open minded on this PR. PRs of interest to this: #1899, #1954, #1868. Pinging @Westacular as someone who got their hands really dirty on the Agg colour handling - your comments would be very welcome here. Finally, just because I'm not 100% sold on this PR @tacaswell, it doesn't mean I don't appreciate how much effort has been put into this PR, so thank you! Cheers, |
@pelson this addresses issue #2473 which has code to reproduce the problem I am trying to address. It looks like the agg backend renders the background as (0, 0, 0, 0) (transparent black). This work fine for anything which can do alpha-blending, however eps can not, so if you rasterize selected artistist which do not fully fill their bounding box you get a black background filling the rest of the bounding box. By changing the color to (1, 1, 1, 0) (transparent white) I don't think think that backends which can do alpha blending will care (as transparent is transparent), but degrades more gracefully in cases when the backend can't deal with alpha. The change to the test is needed because it is testing the array returned. I don't think that there is any visible change in the pngs. That said, I have only on a few occasions dug down into the Agg rendering so am doing a bit of cargo-cult programming here. I needed issue #2473 fixed for some figures in my thesis and took what I thought was the most direct route, but make no claim it is the best route. |
Thanks for the update @tacaswell. I see your motivation for this change now and @mdboom's comments make a lot more sense to me 😄
Whilst I don't have a problem with this change, the correct fix is much harder (and in general, may not be possible without adding transparency to eps files). My current thoughts are two approaches:
👍 for merging this, but acknowledging that it isn't the "correct" solution. Thanks @tacaswell |
@pelson: I agree with your summary, i.e., this is not a complete solution, but I think it's "less bad" than the status quo. FWIW, Cairo (itself, not our Cairo backend) deals with alpha transparency in PS exactly as you describe in your first bullet: it rasterizes everything up to and including transparent objects. The cairo-based tool "pdftocairo" will do this as well. I'd suggest that that is not a terrible solution to point users to -- either using our Cairo backend or outputting PDF and converting with Your second suggestion is interesting -- in the general case, you could end up with really large clip paths, I suppose. |
@pelson That is true, but without these changes, the white region would just be replaced with a black region and it is still just as broken. There are cases (such as what drove me to do this) where a white region is less broken than a black region. As a side note, is there an easy way for me to change an issue into a PR? That would have lead to less confusion in this case. |
That is precisely what I meant with the statements: |
Sorry, just making sure every one was on the same page. |
Set default agg canvas background color to ```(1, 1, 1, 0)```, rather than ```(0, 0, 0, 0)```.
@mdboom Can this be cherry picked to master? (should I just do it?) |
This will get merged back to master by hand at some point - @mdboom and myself do this fairly regularly. Would it be helpful to you for me to do that now? |
Yes. I need this along with a few other branches on master to generate the figures for my thesis. It would make my life easier if this were in master |
Set default agg canvas background color to ```(1, 1, 1, 0)```, rather than ```(0, 0, 0, 0)```.
Ok @tacaswell - hopefully that will make life easier for you. Commit to master: 06d0144 |
thanks |
Sorry for reviving, but I just stumbled upon the same issue and would need a black clearing color. It's really a shame that it cannot be set manually from Python world. I tried calling |
@neothemachine Sorry about breaking things for you! iirc there was discussion of being able to pass this value through, could you make a new issue to make sure it does not get lost. |
Addresses issue #2473