Return the codes and vertices for a rotated, scaled, and translated 90 degree arc. Other Parameters ---------------- quadrant : {0, 1, 2, 3}, default: 0 Uses 0-based indexing (0, 1, 2, or 3). cw : bool, default: True If True,
(self, quadrant=0, cw=True, radius=1, center=(0, 0))
| 167 | self.add(**kwargs) |
| 168 | |
| 169 | def _arc(self, quadrant=0, cw=True, radius=1, center=(0, 0)): |
| 170 | """ |
| 171 | Return the codes and vertices for a rotated, scaled, and translated |
| 172 | 90 degree arc. |
| 173 | |
| 174 | Other Parameters |
| 175 | ---------------- |
| 176 | quadrant : {0, 1, 2, 3}, default: 0 |
| 177 | Uses 0-based indexing (0, 1, 2, or 3). |
| 178 | cw : bool, default: True |
| 179 | If True, the arc vertices are produced clockwise; counter-clockwise |
| 180 | otherwise. |
| 181 | radius : float, default: 1 |
| 182 | The radius of the arc. |
| 183 | center : (float, float), default: (0, 0) |
| 184 | (x, y) tuple of the arc's center. |
| 185 | """ |
| 186 | # Note: It would be possible to use matplotlib's transforms to rotate, |
| 187 | # scale, and translate the arc, but since the angles are discrete, |
| 188 | # it's just as easy and maybe more efficient to do it here. |
| 189 | ARC_CODES = [Path.LINETO, |
| 190 | Path.CURVE4, |
| 191 | Path.CURVE4, |
| 192 | Path.CURVE4, |
| 193 | Path.CURVE4, |
| 194 | Path.CURVE4, |
| 195 | Path.CURVE4] |
| 196 | # Vertices of a cubic Bezier curve approximating a 90 deg arc |
| 197 | # These can be determined by Path.arc(0, 90). |
| 198 | ARC_VERTICES = np.array([[1.00000000e+00, 0.00000000e+00], |
| 199 | [1.00000000e+00, 2.65114773e-01], |
| 200 | [8.94571235e-01, 5.19642327e-01], |
| 201 | [7.07106781e-01, 7.07106781e-01], |
| 202 | [5.19642327e-01, 8.94571235e-01], |
| 203 | [2.65114773e-01, 1.00000000e+00], |
| 204 | # Insignificant |
| 205 | # [6.12303177e-17, 1.00000000e+00]]) |
| 206 | [0.00000000e+00, 1.00000000e+00]]) |
| 207 | if quadrant in (0, 2): |
| 208 | if cw: |
| 209 | vertices = ARC_VERTICES |
| 210 | else: |
| 211 | vertices = ARC_VERTICES[:, ::-1] # Swap x and y. |
| 212 | else: # 1, 3 |
| 213 | # Negate x. |
| 214 | if cw: |
| 215 | # Swap x and y. |
| 216 | vertices = np.column_stack((-ARC_VERTICES[:, 1], |
| 217 | ARC_VERTICES[:, 0])) |
| 218 | else: |
| 219 | vertices = np.column_stack((-ARC_VERTICES[:, 0], |
| 220 | ARC_VERTICES[:, 1])) |
| 221 | if quadrant > 1: |
| 222 | radius = -radius # Rotate 180 deg. |
| 223 | return list(zip(ARC_CODES, radius * vertices + |
| 224 | np.tile(center, (ARC_VERTICES.shape[0], 1)))) |
| 225 | |
| 226 | def _add_input(self, path, angle, flow, length): |
no outgoing calls
no test coverage detected