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

Method clip_cmd

lib/matplotlib/backends/backend_pdf.py:2508–2526  ·  view source on GitHub ↗

Set clip rectangle. Calls `.pop()` and `.push()`.

(self, cliprect, clippath)

Source from the content-addressed store, hash-verified

2506 return [Op.grestore]
2507
2508 def clip_cmd(self, cliprect, clippath):
2509 """Set clip rectangle. Calls `.pop()` and `.push()`."""
2510 cmds = []
2511 # Pop graphics state until we hit the right one or the stack is empty
2512 while ((self._cliprect, self._clippath) != (cliprect, clippath)
2513 and self.parent is not None):
2514 cmds.extend(self.pop())
2515 # Unless we hit the right one, set the clip polygon
2516 if ((self._cliprect, self._clippath) != (cliprect, clippath) or
2517 self.parent is None):
2518 cmds.extend(self.push())
2519 if self._cliprect != cliprect:
2520 cmds.extend([cliprect, Op.rectangle, Op.clip, Op.endpath])
2521 if self._clippath != clippath:
2522 path, affine = clippath.get_transformed_path_and_affine()
2523 cmds.extend(
2524 PdfFile.pathOperations(path, affine, simplify=False) +
2525 [Op.clip, Op.endpath])
2526 return cmds
2527
2528 commands = (
2529 # must come first since may pop

Callers

nothing calls this directly

Calls 4

popMethod · 0.95
pushMethod · 0.95
pathOperationsMethod · 0.80

Tested by

no test coverage detected