Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MNT: Remove unused code in pdf backend #4739

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

Merged
merged 1 commit into from
Jul 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 19 additions & 33 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,17 @@ def pdfRepr(self):
for name, value in six.iteritems(_pdfops)]))


def _paint_path(closep, fillp, strokep):
def _paint_path(fill, stroke):
"""Return the PDF operator to paint a path in the following way:
closep: close the path before painting
fillp: fill the path with the fill color
strokep: stroke the outline of the path with the line color"""
if strokep:
if closep:
if fillp:
return Op.close_fill_stroke
else:
return Op.close_stroke
fill: fill the path with the fill color
stroke: stroke the outline of the path with the line color"""
if stroke:
if fill:
return Op.fill_stroke
else:
if fillp:
return Op.fill_stroke
else:
return Op.stroke
return Op.stroke
else:
if fillp:
if fill:
return Op.fill
else:
return Op.endpath
Expand Down Expand Up @@ -1322,7 +1315,7 @@ def writeImages(self):
self.currentstream.write(data)
self.endStream()

def markerObject(self, path, trans, fillp, strokep, lw, joinstyle,
def markerObject(self, path, trans, fill, stroke, lw, joinstyle,
capstyle):
"""Return name of a marker XObject representing the given path."""
# self.markers used by markerObject, writeMarkers, close:
Expand All @@ -1338,7 +1331,7 @@ def markerObject(self, path, trans, fillp, strokep, lw, joinstyle,
# first two components of each value in self.markers to be the
# name and object reference.
pathops = self.pathOperations(path, trans, simplify=False)
key = (tuple(pathops), bool(fillp), bool(strokep), joinstyle, capstyle)
key = (tuple(pathops), bool(fill), bool(stroke), joinstyle, capstyle)
result = self.markers.get(key)
if result is None:
name = Name('M%d' % len(self.markers))
Expand All @@ -1352,7 +1345,7 @@ def markerObject(self, path, trans, fillp, strokep, lw, joinstyle,
return name

def writeMarkers(self):
for ((pathops, fillp, strokep, joinstyle, capstyle),
for ((pathops, fill, stroke, joinstyle, capstyle),
(name, ob, bbox, lw)) in six.iteritems(self.markers):
bbox = bbox.padded(lw * 0.5)
self.beginStream(
Expand All @@ -1363,7 +1356,7 @@ def writeMarkers(self):
Op.setlinejoin)
self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap)
self.output(*pathops)
self.output(Op.paint_path(False, fillp, strokep))
self.output(Op.paint_path(fill, stroke))
self.endStream()

def pathCollectionObject(self, gc, path, trans, padding, filled, stroked):
Expand Down Expand Up @@ -1392,7 +1385,7 @@ def writePathCollectionTemplates(self):
Op.setlinejoin)
self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap)
self.output(*pathops)
self.output(Op.paint_path(False, filled, stroked))
self.output(Op.paint_path(filled, stroked))
self.endStream()

@staticmethod
Expand Down Expand Up @@ -1690,12 +1683,12 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans,
return

self.check_gc(gc, rgbFace)
fillp = gc.fillp(rgbFace)
strokep = gc.strokep()
fill = gc.fill(rgbFace)
stroke = gc.stroke()

output = self.file.output
marker = self.file.markerObject(
marker_path, marker_trans, fillp, strokep, self.gc._linewidth,
marker_path, marker_trans, fill, stroke, self.gc._linewidth,
gc.get_joinstyle(), gc.get_capstyle())

output(Op.gsave)
Expand Down Expand Up @@ -2136,7 +2129,7 @@ def __repr__(self):
del d['parent']
return repr(d)

def strokep(self):
def stroke(self):
"""
Predicate: does the path need to be stroked (its outline drawn)?
This tests for the various conditions that disable stroking
Expand All @@ -2147,7 +2140,7 @@ def strokep(self):
return (self._linewidth > 0 and self._alpha > 0 and
(len(self._rgb) <= 3 or self._rgb[3] != 0.0))

def fillp(self, *args):
def fill(self, *args):
"""
Predicate: does the path need to be filled?

Expand All @@ -2162,19 +2155,12 @@ def fillp(self, *args):
(_fillcolor is not None and
(len(_fillcolor) <= 3 or _fillcolor[3] != 0.0)))

def close_and_paint(self):
"""
Return the appropriate pdf operator to close the path and
cause it to be stroked, filled, or both.
"""
return Op.paint_path(True, self.fillp(), self.strokep())

def paint(self):
"""
Return the appropriate pdf operator to cause the path to be
stroked, filled, or both.
"""
return Op.paint_path(False, self.fillp(), self.strokep())
return Op.paint_path(self.fill(), self.stroke())

capstyles = {'butt': 0, 'round': 1, 'projecting': 2}
joinstyles = {'miter': 0, 'round': 1, 'bevel': 2}
Expand Down