| 1358 | self._recompute_path() |
| 1359 | |
| 1360 | def _recompute_path(self): |
| 1361 | # Inner and outer rings are connected unless the annulus is complete |
| 1362 | if abs((self.theta2 - self.theta1) - 360) <= 1e-12: |
| 1363 | theta1, theta2 = 0, 360 |
| 1364 | connector = Path.MOVETO |
| 1365 | else: |
| 1366 | theta1, theta2 = self.theta1, self.theta2 |
| 1367 | connector = Path.LINETO |
| 1368 | |
| 1369 | # Form the outer ring |
| 1370 | arc = Path.arc(theta1, theta2) |
| 1371 | |
| 1372 | if self.width is not None: |
| 1373 | # Partial annulus needs to draw the outer ring |
| 1374 | # followed by a reversed and scaled inner ring |
| 1375 | v1 = arc.vertices |
| 1376 | v2 = arc.vertices[::-1] * (self.r - self.width) / self.r |
| 1377 | v = np.concatenate([v1, v2, [(0, 0)]]) |
| 1378 | c = [*arc.codes, connector, *arc.codes[1:], Path.CLOSEPOLY] |
| 1379 | else: |
| 1380 | # Wedge doesn't need an inner ring |
| 1381 | v = np.concatenate([arc.vertices, [(0, 0), (0, 0)]]) |
| 1382 | c = [*arc.codes, connector, Path.CLOSEPOLY] |
| 1383 | |
| 1384 | # Shift and scale the wedge to the final location. |
| 1385 | self._path = Path(v * self.r + self.center, c) |
| 1386 | |
| 1387 | def set_center(self, center): |
| 1388 | self._path = None |