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

Method __call__

lib/matplotlib/patches.py:2615–2654  ·  view source on GitHub ↗
(self, x0, y0, width, height, mutation_size)

Source from the content-addressed store, hash-verified

2613 self.head_angle = head_angle
2614
2615 def __call__(self, x0, y0, width, height, mutation_size):
2616 # padding & padded dimensions
2617 pad = mutation_size * self.pad
2618 dx, dy = width + 2 * pad, height + 2 * pad
2619 x0, y0 = x0 - pad, y0 - pad,
2620 x1, y1 = x0 + dx, y0 + dy
2621
2622 head_dy = self.head_width * dy
2623 mid_y = (y0 + y1) / 2
2624 shaft_y0 = mid_y - head_dy / 2
2625 shaft_y1 = mid_y + head_dy / 2
2626
2627 cot = 1 / math.tan(math.radians(self.head_angle / 2))
2628
2629 if cot > 0:
2630 # tip_x is chosen s.t. the angled line moving back from the tip hits
2631 # i) if head_width > 1: the box corner, or ii) if head_width <
2632 # 1 the box edge at the point giving the correct shaft width.
2633 tip_x = x1 + cot * min(dy, head_dy) / 2
2634 shaft_x = tip_x - cot * head_dy / 2
2635 return Path._create_closed([
2636 (x0, y0), (shaft_x, y0), (shaft_x, shaft_y0),
2637 (tip_x, mid_y),
2638 (shaft_x, shaft_y1), (shaft_x, y1), (x0, y1),
2639 ])
2640 else: # Reverse arrowhead.
2641 # Make the long (outer) side of the arrowhead flush with the
2642 # original box, and move back accordingly (but clipped to no
2643 # more than the box length). If this clipping is necessary,
2644 # the y positions at the short (inner) side of the arrowhead
2645 # will be thicker than the original box, hence the need to
2646 # recompute mid_y0 & mid_y1.
2647 # If head_width < 1 no arrowhead is drawn.
2648 dx = min(-cot * max(head_dy - dy, 0) / 2, dx) # cot < 0!
2649 mid_y0 = min(shaft_y0, y0) - dx / cot
2650 mid_y1 = max(shaft_y1, y1) + dx / cot
2651 return Path._create_closed([
2652 (x0, y0), (x1 - dx, mid_y0), (x1, shaft_y0),
2653 (x1, shaft_y1), (x1 - dx, mid_y1), (x0, y1),
2654 ])
2655
2656 @_register_style(_style_list)
2657 class LArrow(RArrow):

Callers

nothing calls this directly

Calls 1

_create_closedMethod · 0.80

Tested by

no test coverage detected