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

Method transmute

lib/matplotlib/patches.py:3843–3899  ·  view source on GitHub ↗
(self, path, mutation_size, linewidth)

Source from the content-addressed store, hash-verified

3841 super().__init__()
3842
3843 def transmute(self, path, mutation_size, linewidth):
3844 # docstring inherited
3845 x0, y0, x1, y1, x2, y2 = self.ensure_quadratic_bezier(path)
3846
3847 # divide the path into a head and a tail
3848 head_length = self.head_length * mutation_size
3849 in_f = inside_circle(x2, y2, head_length)
3850 arrow_path = [(x0, y0), (x1, y1), (x2, y2)]
3851
3852 try:
3853 arrow_out, arrow_in = \
3854 split_bezier_intersecting_with_closedpath(arrow_path, in_f)
3855 except NonIntersectingPathException:
3856 # if this happens, make a straight line of the head_length
3857 # long.
3858 x0, y0 = _point_along_a_line(x2, y2, x1, y1, head_length)
3859 x1n, y1n = 0.5 * (x0 + x2), 0.5 * (y0 + y2)
3860 arrow_in = [(x0, y0), (x1n, y1n), (x2, y2)]
3861 arrow_out = None
3862
3863 # head
3864 head_width = self.head_width * mutation_size
3865 head_left, head_right = make_wedged_bezier2(arrow_in,
3866 head_width / 2., wm=.5)
3867
3868 # tail
3869 if arrow_out is not None:
3870 tail_width = self.tail_width * mutation_size
3871 tail_left, tail_right = get_parallels(arrow_out,
3872 tail_width / 2.)
3873
3874 patch_path = [(Path.MOVETO, tail_right[0]),
3875 (Path.CURVE3, tail_right[1]),
3876 (Path.CURVE3, tail_right[2]),
3877 (Path.LINETO, head_right[0]),
3878 (Path.CURVE3, head_right[1]),
3879 (Path.CURVE3, head_right[2]),
3880 (Path.CURVE3, head_left[1]),
3881 (Path.CURVE3, head_left[0]),
3882 (Path.LINETO, tail_left[2]),
3883 (Path.CURVE3, tail_left[1]),
3884 (Path.CURVE3, tail_left[0]),
3885 (Path.LINETO, tail_right[0]),
3886 (Path.CLOSEPOLY, tail_right[0]),
3887 ]
3888 else:
3889 patch_path = [(Path.MOVETO, head_right[0]),
3890 (Path.CURVE3, head_right[1]),
3891 (Path.CURVE3, head_right[2]),
3892 (Path.CURVE3, head_left[1]),
3893 (Path.CURVE3, head_left[0]),
3894 (Path.CLOSEPOLY, head_left[0]),
3895 ]
3896
3897 path = Path([p for c, p in patch_path], [c for c, p in patch_path])
3898
3899 return path, True
3900

Callers

nothing calls this directly

Calls 7

inside_circleFunction · 0.85
_point_along_a_lineFunction · 0.85
make_wedged_bezier2Function · 0.85
get_parallelsFunction · 0.85
PathClass · 0.85

Tested by

no test coverage detected