MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / connect

Method connect

lib/matplotlib/patches.py:3169–3226  ·  view source on GitHub ↗
(self, posA, posB)

Source from the content-addressed store, hash-verified

3167 self.rad = rad
3168
3169 def connect(self, posA, posB):
3170 x1, y1 = posA
3171 x2, y2 = posB
3172
3173 vertices = [(x1, y1)]
3174 rounded = []
3175 codes = [Path.MOVETO]
3176
3177 if self.armA:
3178 cosA = math.cos(math.radians(self.angleA))
3179 sinA = math.sin(math.radians(self.angleA))
3180 # x_armA, y_armB
3181 d = self.armA - self.rad
3182 rounded.append((x1 + d * cosA, y1 + d * sinA))
3183 d = self.armA
3184 rounded.append((x1 + d * cosA, y1 + d * sinA))
3185
3186 if self.armB:
3187 cosB = math.cos(math.radians(self.angleB))
3188 sinB = math.sin(math.radians(self.angleB))
3189 x_armB, y_armB = x2 + self.armB * cosB, y2 + self.armB * sinB
3190
3191 if rounded:
3192 xp, yp = rounded[-1]
3193 dx, dy = x_armB - xp, y_armB - yp
3194 dd = (dx * dx + dy * dy) ** .5
3195
3196 rounded.append((xp + self.rad * dx / dd,
3197 yp + self.rad * dy / dd))
3198 vertices.extend(rounded)
3199 codes.extend([Path.LINETO,
3200 Path.CURVE3,
3201 Path.CURVE3])
3202 else:
3203 xp, yp = vertices[-1]
3204 dx, dy = x_armB - xp, y_armB - yp
3205 dd = (dx * dx + dy * dy) ** .5
3206
3207 d = dd - self.rad
3208 rounded = [(xp + d * dx / dd, yp + d * dy / dd),
3209 (x_armB, y_armB)]
3210
3211 if rounded:
3212 xp, yp = rounded[-1]
3213 dx, dy = x2 - xp, y2 - yp
3214 dd = (dx * dx + dy * dy) ** .5
3215
3216 rounded.append((xp + self.rad * dx / dd,
3217 yp + self.rad * dy / dd))
3218 vertices.extend(rounded)
3219 codes.extend([Path.LINETO,
3220 Path.CURVE3,
3221 Path.CURVE3])
3222
3223 vertices.append((x2, y2))
3224 codes.append(Path.LINETO)
3225
3226 return Path(vertices, codes)

Callers 1

__call__Method · 0.45

Calls 1

PathClass · 0.85

Tested by

no test coverage detected