MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / GraphicsContextPdf

Class GraphicsContextPdf

lib/matplotlib/backends/backend_pdf.py:2396–2598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2394
2395
2396class GraphicsContextPdf(GraphicsContextBase):
2397
2398 def __init__(self, file):
2399 super().__init__()
2400 self._fillcolor = (0.0, 0.0, 0.0)
2401 self._effective_alphas = (1.0, 1.0)
2402 self.file = file
2403 self.parent = None
2404
2405 def __repr__(self):
2406 d = dict(self.__dict__)
2407 del d['file']
2408 del d['parent']
2409 return repr(d)
2410
2411 def stroke(self):
2412 """
2413 Predicate: does the path need to be stroked (its outline drawn)?
2414 This tests for the various conditions that disable stroking
2415 the path, in which case it would presumably be filled.
2416 """
2417 # _linewidth > 0: in pdf a line of width 0 is drawn at minimum
2418 # possible device width, but e.g., agg doesn't draw at all
2419 return (self._linewidth > 0 and self._alpha > 0 and
2420 (len(self._rgb) <= 3 or self._rgb[3] != 0.0))
2421
2422 def fill(self, *args):
2423 """
2424 Predicate: does the path need to be filled?
2425
2426 An optional argument can be used to specify an alternative
2427 _fillcolor, as needed by RendererPdf.draw_markers.
2428 """
2429 if len(args):
2430 _fillcolor = args[0]
2431 else:
2432 _fillcolor = self._fillcolor
2433 return (self._hatch or
2434 (_fillcolor is not None and
2435 (len(_fillcolor) <= 3 or _fillcolor[3] != 0.0)))
2436
2437 def paint(self):
2438 """
2439 Return the appropriate pdf operator to cause the path to be
2440 stroked, filled, or both.
2441 """
2442 return Op.paint_path(self.fill(), self.stroke())
2443
2444 capstyles = {'butt': 0, 'round': 1, 'projecting': 2}
2445 joinstyles = {'miter': 0, 'round': 1, 'bevel': 2}
2446
2447 def capstyle_cmd(self, style):
2448 return [self.capstyles[style], Op.setlinecap]
2449
2450 def joinstyle_cmd(self, style):
2451 return [self.joinstyles[style], Op.setlinejoin]
2452
2453 def linewidth_cmd(self, width):

Callers 2

new_gcMethod · 0.85
pushMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…