(self, gc, path, transform, rgbFace=None)
| 433 | _writeln(self.fh, r"\end{pgfscope}") |
| 434 | |
| 435 | def draw_path(self, gc, path, transform, rgbFace=None): |
| 436 | # docstring inherited |
| 437 | _writeln(self.fh, r"\begin{pgfscope}") |
| 438 | # draw the path |
| 439 | self._print_pgf_clip(gc) |
| 440 | self._print_pgf_path_styles(gc, rgbFace) |
| 441 | self._print_pgf_path(gc, path, transform, rgbFace) |
| 442 | self._pgf_path_draw(stroke=gc.get_linewidth() != 0.0, |
| 443 | fill=rgbFace is not None) |
| 444 | _writeln(self.fh, r"\end{pgfscope}") |
| 445 | |
| 446 | # if present, draw pattern on top |
| 447 | if gc.get_hatch(): |
| 448 | _writeln(self.fh, r"\begin{pgfscope}") |
| 449 | self._print_pgf_path_styles(gc, rgbFace) |
| 450 | |
| 451 | # combine clip and path for clipping |
| 452 | self._print_pgf_clip(gc) |
| 453 | self._print_pgf_path(gc, path, transform, rgbFace) |
| 454 | _writeln(self.fh, r"\pgfusepath{clip}") |
| 455 | |
| 456 | # build pattern definition |
| 457 | _writeln(self.fh, |
| 458 | r"\pgfsys@defobject{currentpattern}" |
| 459 | r"{\pgfqpoint{0in}{0in}}{\pgfqpoint{1in}{1in}}{") |
| 460 | _writeln(self.fh, r"\begin{pgfscope}") |
| 461 | _writeln(self.fh, |
| 462 | r"\pgfpathrectangle" |
| 463 | r"{\pgfqpoint{0in}{0in}}{\pgfqpoint{1in}{1in}}") |
| 464 | _writeln(self.fh, r"\pgfusepath{clip}") |
| 465 | scale = mpl.transforms.Affine2D().scale(self.dpi) |
| 466 | self._print_pgf_path(None, gc.get_hatch_path(), scale) |
| 467 | self._pgf_path_draw(stroke=True) |
| 468 | _writeln(self.fh, r"\end{pgfscope}") |
| 469 | _writeln(self.fh, r"}") |
| 470 | # repeat pattern, filling the bounding rect of the path |
| 471 | f = 1. / self.dpi |
| 472 | (xmin, ymin), (xmax, ymax) = \ |
| 473 | path.get_extents(transform).get_points() |
| 474 | xmin, xmax = f * xmin, f * xmax |
| 475 | ymin, ymax = f * ymin, f * ymax |
| 476 | repx, repy = math.ceil(xmax - xmin), math.ceil(ymax - ymin) |
| 477 | _writeln(self.fh, |
| 478 | r"\pgfsys@transformshift{%fin}{%fin}" % (xmin, ymin)) |
| 479 | for iy in range(repy): |
| 480 | for ix in range(repx): |
| 481 | _writeln(self.fh, r"\pgfsys@useobject{currentpattern}{}") |
| 482 | _writeln(self.fh, r"\pgfsys@transformshift{1in}{0in}") |
| 483 | _writeln(self.fh, r"\pgfsys@transformshift{-%din}{0in}" % repx) |
| 484 | _writeln(self.fh, r"\pgfsys@transformshift{0in}{1in}") |
| 485 | |
| 486 | _writeln(self.fh, r"\end{pgfscope}") |
| 487 | |
| 488 | def _print_pgf_clip(self, gc): |
| 489 | f = 1. / self.dpi |
nothing calls this directly
no test coverage detected