(self, path, mutation_size, linewidth)
| 3920 | super().__init__() |
| 3921 | |
| 3922 | def transmute(self, path, mutation_size, linewidth): |
| 3923 | # docstring inherited |
| 3924 | x0, y0, x1, y1, x2, y2 = self.ensure_quadratic_bezier(path) |
| 3925 | |
| 3926 | # divide the path into a head and a tail |
| 3927 | head_length = self.head_length * mutation_size |
| 3928 | arrow_path = [(x0, y0), (x1, y1), (x2, y2)] |
| 3929 | |
| 3930 | # path for head |
| 3931 | in_f = inside_circle(x2, y2, head_length) |
| 3932 | try: |
| 3933 | path_out, path_in = split_bezier_intersecting_with_closedpath( |
| 3934 | arrow_path, in_f) |
| 3935 | except NonIntersectingPathException: |
| 3936 | # if this happens, make a straight line of the head_length |
| 3937 | # long. |
| 3938 | x0, y0 = _point_along_a_line(x2, y2, x1, y1, head_length) |
| 3939 | x1n, y1n = 0.5 * (x0 + x2), 0.5 * (y0 + y2) |
| 3940 | arrow_path = [(x0, y0), (x1n, y1n), (x2, y2)] |
| 3941 | path_head = arrow_path |
| 3942 | else: |
| 3943 | path_head = path_in |
| 3944 | |
| 3945 | # path for head |
| 3946 | in_f = inside_circle(x2, y2, head_length * .8) |
| 3947 | path_out, path_in = split_bezier_intersecting_with_closedpath( |
| 3948 | arrow_path, in_f) |
| 3949 | path_tail = path_out |
| 3950 | |
| 3951 | # head |
| 3952 | head_width = self.head_width * mutation_size |
| 3953 | head_l, head_r = make_wedged_bezier2(path_head, |
| 3954 | head_width / 2., |
| 3955 | wm=.6) |
| 3956 | |
| 3957 | # tail |
| 3958 | tail_width = self.tail_width * mutation_size |
| 3959 | tail_left, tail_right = make_wedged_bezier2(path_tail, |
| 3960 | tail_width * .5, |
| 3961 | w1=1., wm=0.6, w2=0.3) |
| 3962 | |
| 3963 | # path for head |
| 3964 | in_f = inside_circle(x0, y0, tail_width * .3) |
| 3965 | path_in, path_out = split_bezier_intersecting_with_closedpath( |
| 3966 | arrow_path, in_f) |
| 3967 | tail_start = path_in[-1] |
| 3968 | |
| 3969 | head_right, head_left = head_r, head_l |
| 3970 | patch_path = [(Path.MOVETO, tail_start), |
| 3971 | (Path.LINETO, tail_right[0]), |
| 3972 | (Path.CURVE3, tail_right[1]), |
| 3973 | (Path.CURVE3, tail_right[2]), |
| 3974 | (Path.LINETO, head_right[0]), |
| 3975 | (Path.CURVE3, head_right[1]), |
| 3976 | (Path.CURVE3, head_right[2]), |
| 3977 | (Path.CURVE3, head_left[1]), |
| 3978 | (Path.CURVE3, head_left[0]), |
| 3979 | (Path.LINETO, tail_left[2]), |
nothing calls this directly
no test coverage detected