-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
When drawing markers, don't set the GraphicsContext alpha. #11105
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -759,9 +759,8 @@ def draw(self, renderer): | |
gc = renderer.new_gc() | ||
self._set_gc_clip(gc) | ||
|
||
ln_color_rgba = self._get_rgba_ln_color() | ||
gc.set_foreground(ln_color_rgba, isRGBA=True) | ||
gc.set_alpha(ln_color_rgba[3]) | ||
lc_rgba = mcolors.to_rgba(self._color, self._alpha) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. As a general rule, an explicit alpha will override one that comes "with the color" (we can always discuss whether that's a good strategy (I think it's a mess) but that's what we have for now). The exception is the one noted in the comment re: markeredgecolor. |
||
gc.set_foreground(lc_rgba, isRGBA=True) | ||
|
||
gc.set_antialiased(self._antialiased) | ||
gc.set_linewidth(self._linewidth) | ||
|
@@ -785,24 +784,23 @@ def draw(self, renderer): | |
if self._marker and self._markersize > 0: | ||
gc = renderer.new_gc() | ||
self._set_gc_clip(gc) | ||
rgbaFace = self._get_rgba_face() | ||
rgbaFaceAlt = self._get_rgba_face(alt=True) | ||
edgecolor = self.get_markeredgecolor() | ||
if cbook._str_lower_equal(edgecolor, "none"): | ||
gc.set_linewidth(0) | ||
gc.set_foreground(rgbaFace, isRGBA=True) | ||
else: | ||
gc.set_foreground(edgecolor) | ||
gc.set_linewidth(self._markeredgewidth) | ||
mec = self._markeredgecolor | ||
if (cbook._str_equal(mec, "auto") | ||
and not cbook._str_lower_equal( | ||
self.get_markerfacecolor(), "none")): | ||
gc.set_alpha(rgbaFace[3]) | ||
else: | ||
gc.set_alpha(self.get_alpha()) | ||
gc.set_linewidth(self._markeredgewidth) | ||
gc.set_antialiased(self._antialiased) | ||
|
||
ec_rgba = mcolors.to_rgba( | ||
self.get_markeredgecolor(), self._alpha) | ||
fc_rgba = mcolors.to_rgba( | ||
self._get_markerfacecolor(), self._alpha) | ||
fcalt_rgba = mcolors.to_rgba( | ||
self._get_markerfacecolor(alt=True), self._alpha) | ||
# If the edgecolor is "auto", it is set according to the *line* | ||
# color but inherits the alpha value of the *face* color, if any. | ||
if (cbook._str_equal(self._markeredgecolor, "auto") | ||
and not cbook._str_lower_equal( | ||
self.get_markerfacecolor(), "none")): | ||
ec_rgba = ec_rgba[:3] + (fc_rgba[3],) | ||
gc.set_foreground(ec_rgba, isRGBA=True) | ||
|
||
marker = self._marker | ||
tpath, affine = transf_path.get_transformed_points_and_affine() | ||
if len(tpath.vertices): | ||
|
@@ -832,22 +830,15 @@ def draw(self, renderer): | |
|
||
renderer.draw_markers(gc, marker_path, marker_trans, | ||
subsampled, affine.frozen(), | ||
rgbaFace) | ||
fc_rgba) | ||
|
||
alt_marker_path = marker.get_alt_path() | ||
if alt_marker_path: | ||
alt_marker_trans = marker.get_alt_transform() | ||
alt_marker_trans = alt_marker_trans.scale(w) | ||
if (cbook._str_equal(mec, "auto") | ||
and not cbook._str_lower_equal( | ||
self.get_markerfacecoloralt(), "none")): | ||
gc.set_alpha(rgbaFaceAlt[3]) | ||
else: | ||
gc.set_alpha(self.get_alpha()) | ||
|
||
renderer.draw_markers( | ||
gc, alt_marker_path, alt_marker_trans, subsampled, | ||
affine.frozen(), rgbaFaceAlt) | ||
affine.frozen(), fcalt_rgba) | ||
|
||
gc.restore() | ||
|
||
|
@@ -892,8 +883,7 @@ def _get_markerfacecolor(self, alt=False): | |
fc = self._markerfacecoloralt | ||
else: | ||
fc = self._markerfacecolor | ||
|
||
if (isinstance(fc, six.string_types) and fc.lower() == 'auto'): | ||
if cbook._str_lower_equal(fc, 'auto'): | ||
if self.get_fillstyle() == 'none': | ||
return 'none' | ||
else: | ||
|
@@ -1253,9 +1243,6 @@ def update_from(self, other): | |
def _get_rgba_face(self, alt=False): | ||
return mcolors.to_rgba(self._get_markerfacecolor(alt=alt), self._alpha) | ||
|
||
def _get_rgba_ln_color(self, alt=False): | ||
return mcolors.to_rgba(self._color, self._alpha) | ||
|
||
def set_dash_joinstyle(self, s): | ||
""" | ||
Set the join style for dashed linestyles | ||
|
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.
This effectively treats alpha as a bool for ps?
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.
We do the same for text.