The renderer handles all the drawing primitives using a graphics context instance that controls the colors/styles
| 57 | |
| 58 | |
| 59 | class RendererAgg(RendererBase): |
| 60 | """ |
| 61 | The renderer handles all the drawing primitives using a graphics |
| 62 | context instance that controls the colors/styles |
| 63 | """ |
| 64 | |
| 65 | def __init__(self, width, height, dpi): |
| 66 | super().__init__() |
| 67 | |
| 68 | self.dpi = dpi |
| 69 | self.width = width |
| 70 | self.height = height |
| 71 | self._renderer = _RendererAgg(int(width), int(height), dpi) |
| 72 | self._filter_renderers = [] |
| 73 | |
| 74 | self._update_methods() |
| 75 | self.mathtext_parser = MathTextParser('path') |
| 76 | |
| 77 | self.bbox = Bbox.from_bounds(0, 0, self.width, self.height) |
| 78 | |
| 79 | def __getstate__(self): |
| 80 | # We only want to preserve the init keywords of the Renderer. |
| 81 | # Anything else can be re-created. |
| 82 | return {'width': self.width, 'height': self.height, 'dpi': self.dpi} |
| 83 | |
| 84 | def __setstate__(self, state): |
| 85 | self.__init__(state['width'], state['height'], state['dpi']) |
| 86 | |
| 87 | def _update_methods(self): |
| 88 | self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles |
| 89 | self.draw_image = self._renderer.draw_image |
| 90 | self.draw_markers = self._renderer.draw_markers |
| 91 | self.draw_path_collection = self._renderer.draw_path_collection |
| 92 | self.draw_quad_mesh = self._renderer.draw_quad_mesh |
| 93 | self.copy_from_bbox = self._renderer.copy_from_bbox |
| 94 | |
| 95 | def draw_path(self, gc, path, transform, rgbFace=None): |
| 96 | # docstring inherited |
| 97 | nmax = mpl.rcParams['agg.path.chunksize'] # here at least for testing |
| 98 | npts = path.vertices.shape[0] |
| 99 | |
| 100 | if (npts > nmax > 100 and path.should_simplify and |
| 101 | rgbFace is None and gc.get_hatch() is None): |
| 102 | nch = np.ceil(npts / nmax) |
| 103 | chsize = int(np.ceil(npts / nch)) |
| 104 | i0 = np.arange(0, npts, chsize) |
| 105 | i1 = np.zeros_like(i0) |
| 106 | i1[:-1] = i0[1:] - 1 |
| 107 | i1[-1] = npts |
| 108 | for ii0, ii1 in zip(i0, i1): |
| 109 | v = path.vertices[ii0:ii1, :] |
| 110 | c = path.codes |
| 111 | if c is not None: |
| 112 | c = c[ii0:ii1] |
| 113 | c[0] = Path.MOVETO # move to end of last chunk |
| 114 | p = Path(v, c) |
| 115 | p.simplify_threshold = path.simplify_threshold |
| 116 | try: |
no outgoing calls
searching dependent graphs…