Return name of a marker XObject representing the given path.
(self, path, trans, fill, stroke, lw, joinstyle,
capstyle)
| 1722 | self._writeImg(data, ob.id, smaskObject) |
| 1723 | |
| 1724 | def markerObject(self, path, trans, fill, stroke, lw, joinstyle, |
| 1725 | capstyle): |
| 1726 | """Return name of a marker XObject representing the given path.""" |
| 1727 | # self.markers used by markerObject, writeMarkers, close: |
| 1728 | # mapping from (path operations, fill?, stroke?) to |
| 1729 | # [name, object reference, bounding box, linewidth] |
| 1730 | # This enables different draw_markers calls to share the XObject |
| 1731 | # if the gc is sufficiently similar: colors etc can vary, but |
| 1732 | # the choices of whether to fill and whether to stroke cannot. |
| 1733 | # We need a bounding box enclosing all of the XObject path, |
| 1734 | # but since line width may vary, we store the maximum of all |
| 1735 | # occurring line widths in self.markers. |
| 1736 | # close() is somewhat tightly coupled in that it expects the |
| 1737 | # first two components of each value in self.markers to be the |
| 1738 | # name and object reference. |
| 1739 | pathops = self.pathOperations(path, trans, simplify=False) |
| 1740 | key = (tuple(pathops), bool(fill), bool(stroke), joinstyle, capstyle) |
| 1741 | result = self.markers.get(key) |
| 1742 | if result is None: |
| 1743 | name = Name('M%d' % len(self.markers)) |
| 1744 | ob = self.reserveObject('marker %d' % len(self.markers)) |
| 1745 | bbox = path.get_extents(trans) |
| 1746 | self.markers[key] = [name, ob, bbox, lw] |
| 1747 | else: |
| 1748 | if result[-1] < lw: |
| 1749 | result[-1] = lw |
| 1750 | name = result[0] |
| 1751 | return name |
| 1752 | |
| 1753 | def writeMarkers(self): |
| 1754 | for ((pathops, fill, stroke, joinstyle, capstyle), |
no test coverage detected