MCPcopy Index your code
hub / github.com/clips/pattern / draw_arrow

Method draw_arrow

pattern/graph/__init__.py:266–283  ·  view source on GitHub ↗

Draws the direction of the edge as an arrow on the rim of the receiving node.

(self, **kwargs)

Source from the content-addressed store, hash-verified

264 self.draw_arrow(stroke=self.stroke, strokewidth=self.strokewidth+w)
265
266 def draw_arrow(self, **kwargs):
267 """ Draws the direction of the edge as an arrow on the rim of the receiving node.
268 """
269 x0, y0 = self.node1.x, self.node1.y
270 x1, y1 = self.node2.x, self.node2.y
271 # Find the edge's angle based on node1 and node2 position.
272 a = degrees(atan2(y1-y0, x1-x0))
273 # The arrow points to node2's rim instead of it's center.
274 r = self.node2.radius
275 d = sqrt(pow(x1-x0, 2) + pow(y1-y0, 2))
276 x01, y01 = coordinates(x0, y0, d-r-1, a)
277 # Find the two other arrow corners under the given angle.
278 r = max(kwargs.get("strokewidth", 1) * 3, 6)
279 dx1, dy1 = coordinates(x01, y01, -r, a-20)
280 dx2, dy2 = coordinates(x01, y01, -r, a+20)
281 line(x01, y01, dx1, dy1, **kwargs)
282 line(x01, y01, dx2, dy2, **kwargs)
283 line(dx1, dy1, dx2, dy2, **kwargs)
284
285 def __repr__(self):
286 return "%s(id1=%s, id2=%s)" % (self.__class__.__name__, repr(self.node1.id), repr(self.node2.id))

Callers 1

drawMethod · 0.95

Calls 2

lineFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected