| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Something is wrong with the hatch color of either collection or patches in svg (but not png). |
Sorry, something went wrong.
| Gets the color to use for hatching. | ||
| """ | ||
| if hatch_color is None: | ||
| raise ValueError() |
There was a problem hiding this comment.
Can you add a message to the error, so that the user understands what's going on?
Sorry, something went wrong.
There was a problem hiding this comment.
Also, don't you want to check that the hatch_color provided is a color? That should fix the value error message.
Sorry, something went wrong.
There was a problem hiding this comment.
this is currently a debugging latch, will probably remove it before final review.
Sorry, something went wrong.
| gc.set_hatch_color(self._hatch_color) | ||
| except AttributeError: | ||
| # if we end up with a GC that does not have this method | ||
| import warnings |
There was a problem hiding this comment.
Any reason not to move this import at the top of the file?
Sorry, something went wrong.
| except AttributeError: | ||
| # if we end up with a GC that does not have this method | ||
| import warnings | ||
| warnings.warn("Your backend does not have support for " |
There was a problem hiding this comment.
"Your backend doesn't support setting the hatch color" is clearer for me (might be because I am a non native english speaker).
Sorry, something went wrong.
|
An eye-ball check confirms that the eps backend is working correctly as well :) |
Sorry, something went wrong.
|
ok, I think I am happy with where this landed (and it ended up being a lot less work (once I understood a few bits of code) than I had anticipated).
Still needs some documentation work which I will do tomorrow. |
Sorry, something went wrong.
|
|
||
| def set_hatch_color(self, hatch_color): | ||
| """ | ||
| Gets the color to use for hatching. |
There was a problem hiding this comment.
typo: Sets
Sorry, something went wrong.
| gc.set_hatch_color(self._hatch_color) | ||
| except AttributeError: | ||
| # if we end up with a GC that does not have this method | ||
| warnings.warn("Your backend does not support setting the " |
There was a problem hiding this comment.
Could you define set_hatch_color in the base graphicscontext class as a noop that prints the warning? (would avoid the repetition below).
Sorry, something went wrong.
There was a problem hiding this comment.
It is defined as a functional function it the base class, this is in case there are backends in the wild that do not derive from our base class.
Sorry, something went wrong.
There was a problem hiding this comment.
Could we suggest them to derive from our base class if they don't have set_hatch_color?
Sorry, something went wrong.
There was a problem hiding this comment.
Why? On the draw method side we are ok duck-typing and the gc objects should belong to the backends so they should free to implement how ever they want.
Sorry, something went wrong.
There was a problem hiding this comment.
Just that it'd be an easy fix to get this working.
Sorry, something went wrong.
There was a problem hiding this comment.
In this particular case, it seems better practice than duck typing :)
Sorry, something went wrong.
There was a problem hiding this comment.
(I am still reviewing this pull request, but I think I'll need some time to get around the code.)
Sorry, something went wrong.
| return [name, Op.setgstate] | ||
|
|
||
| def hatch_cmd(self, hatch): | ||
| def hatch_cmd(self, hatch, hatch_color): |
There was a problem hiding this comment.
Can you explain this extra argument instead of using self._hatch_color?
Sorry, something went wrong.
There was a problem hiding this comment.
Because of the way the pdf backend deals with the fact that internally pdf's have a stack-based graphics context so when we change the gc in the draw methods, the delta method is used to determine what is different between the 'current' gc and the 'gc' that was just passed in. The way that method works is by checking a bunch of internal state and if it needs to be updated emit some commands to the pdf file. hatch_cmd is what generates the hatch commands. To tell if we need to change the hatch we need to check both _hatch and _hatch_color and then all of the parameters you check are passed into the command function (see L2323 ish). And the instance of the gc that the command methods are bound to is the 'old' gc, not the 'new' gc so we have to inject it this way.
It is possible that the pdf backend could be cleaned up, but that is a much bigger project.
sorry this is rambley, but it took me a while to sort this out last night.
Sorry, something went wrong.
There was a problem hiding this comment.
I think I understand…
Sorry, something went wrong.
There was a problem hiding this comment.
I feel the same way 😅
Sorry, something went wrong.
There was a problem hiding this comment.
Also, this is made more complicated by how we implement hatching in pdf: it replaces the fill color with a named pattern. I think the backend_pdf changes are correct, and you added tests for the new functionality so we should be fine.
Sorry, something went wrong.
| gc.set_hatch_color(self._hatch_color) | ||
| except AttributeError: | ||
| # if we end up with a GC that does not have this method | ||
| warnings.warn("Your backend does not support setting the " |
There was a problem hiding this comment.
Could we suggest them to derive from our base class if they don't have set_hatch_color?
Sorry, something went wrong.
|
force-pushed to remove some test-thrashing + add docs. |
Sorry, something went wrong.
There was a problem hiding this comment.
This looks ok to me, but I have to say that I am very happy that there are tests on this section of the code. It also seems very convoluted, so an additional careful review is in order.
Sorry, something went wrong.
| to color the hatches. | ||
|
|
||
| In the future there may also be ``hatch_linewidth`` and | ||
| ``hatch_density`` related methods added. It is encouraged, but not |
There was a problem hiding this comment.
@NelleV Added the 'please derive from us' verbiage here.
Sorry, something went wrong.
There was a problem hiding this comment.
Are you canceling by hand the old travis-ci tests or have we activated the new beta feature to cancel tests on PRs if a newer version exists?
Sorry, something went wrong.
There was a problem hiding this comment.
I am canceling them by hand.
Sorry, something went wrong.
|
|
||
| The color of the lines in the hatch is now determined by | ||
|
|
||
| - If an edge color is explicitly, use that for the hatch color |
There was a problem hiding this comment.
'is explicitly set'
Sorry, something went wrong.
There was a problem hiding this comment.
Pending CI success.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Addresses #7901
Still needs docs and a closer look at the test images that get updated.