Set clip rectangle. Calls `.pop()` and `.push()`.
(self, cliprect, clippath)
| 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 |
nothing calls this directly
no test coverage detected