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

Skip to content

Commit 6e2ee31

Browse files
committed
Merge pull request #4739 from jkseppan/pdf-paint
MNT: Remove unused code in pdf backend
2 parents 5cadac1 + 3fa3d99 commit 6e2ee31

File tree

1 file changed

+19
-33
lines changed

1 file changed

+19
-33
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -309,24 +309,17 @@ def pdfRepr(self):
309309
for name, value in six.iteritems(_pdfops)]))
310310

311311

312-
def _paint_path(closep, fillp, strokep):
312+
def _paint_path(fill, stroke):
313313
"""Return the PDF operator to paint a path in the following way:
314-
closep: close the path before painting
315-
fillp: fill the path with the fill color
316-
strokep: stroke the outline of the path with the line color"""
317-
if strokep:
318-
if closep:
319-
if fillp:
320-
return Op.close_fill_stroke
321-
else:
322-
return Op.close_stroke
314+
fill: fill the path with the fill color
315+
stroke: stroke the outline of the path with the line color"""
316+
if stroke:
317+
if fill:
318+
return Op.fill_stroke
323319
else:
324-
if fillp:
325-
return Op.fill_stroke
326-
else:
327-
return Op.stroke
320+
return Op.stroke
328321
else:
329-
if fillp:
322+
if fill:
330323
return Op.fill
331324
else:
332325
return Op.endpath
@@ -1322,7 +1315,7 @@ def writeImages(self):
13221315
self.currentstream.write(data)
13231316
self.endStream()
13241317

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

13541347
def writeMarkers(self):
1355-
for ((pathops, fillp, strokep, joinstyle, capstyle),
1348+
for ((pathops, fill, stroke, joinstyle, capstyle),
13561349
(name, ob, bbox, lw)) in six.iteritems(self.markers):
13571350
bbox = bbox.padded(lw * 0.5)
13581351
self.beginStream(
@@ -1363,7 +1356,7 @@ def writeMarkers(self):
13631356
Op.setlinejoin)
13641357
self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap)
13651358
self.output(*pathops)
1366-
self.output(Op.paint_path(False, fillp, strokep))
1359+
self.output(Op.paint_path(fill, stroke))
13671360
self.endStream()
13681361

13691362
def pathCollectionObject(self, gc, path, trans, padding, filled, stroked):
@@ -1392,7 +1385,7 @@ def writePathCollectionTemplates(self):
13921385
Op.setlinejoin)
13931386
self.output(GraphicsContextPdf.capstyles[capstyle], Op.setlinecap)
13941387
self.output(*pathops)
1395-
self.output(Op.paint_path(False, filled, stroked))
1388+
self.output(Op.paint_path(filled, stroked))
13961389
self.endStream()
13971390

13981391
@staticmethod
@@ -1690,12 +1683,12 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans,
16901683
return
16911684

16921685
self.check_gc(gc, rgbFace)
1693-
fillp = gc.fillp(rgbFace)
1694-
strokep = gc.strokep()
1686+
fill = gc.fill(rgbFace)
1687+
stroke = gc.stroke()
16951688

16961689
output = self.file.output
16971690
marker = self.file.markerObject(
1698-
marker_path, marker_trans, fillp, strokep, self.gc._linewidth,
1691+
marker_path, marker_trans, fill, stroke, self.gc._linewidth,
16991692
gc.get_joinstyle(), gc.get_capstyle())
17001693

17011694
output(Op.gsave)
@@ -2136,7 +2129,7 @@ def __repr__(self):
21362129
del d['parent']
21372130
return repr(d)
21382131

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

2150-
def fillp(self, *args):
2143+
def fill(self, *args):
21512144
"""
21522145
Predicate: does the path need to be filled?
21532146
@@ -2162,19 +2155,12 @@ def fillp(self, *args):
21622155
(_fillcolor is not None and
21632156
(len(_fillcolor) <= 3 or _fillcolor[3] != 0.0)))
21642157

2165-
def close_and_paint(self):
2166-
"""
2167-
Return the appropriate pdf operator to close the path and
2168-
cause it to be stroked, filled, or both.
2169-
"""
2170-
return Op.paint_path(True, self.fillp(), self.strokep())
2171-
21722158
def paint(self):
21732159
"""
21742160
Return the appropriate pdf operator to cause the path to be
21752161
stroked, filled, or both.
21762162
"""
2177-
return Op.paint_path(False, self.fillp(), self.strokep())
2163+
return Op.paint_path(self.fill(), self.stroke())
21782164

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

0 commit comments

Comments
 (0)