69
71
def _render(self, gc, points, icon_mode=False):
71
gc.clip_to_rect(self.x, self.y, self.width, self.height)
73
gc.set_stroke_color(self.line_color_)
74
gc.set_line_width(self.line_width)
76
# Draw the body of the arrow
78
ends = points + self._cached_vector_data
80
gc.line_set(starts, ends)
83
if self.arrow_size > 0:
84
vec = self._cached_vector_data
85
unit_vec = vec / sqrt(vec[:,0] ** 2 + vec[:,1] ** 2)[:, newaxis]
86
a = 0.707106781 # sqrt(2)/2
88
# Draw the left arrowhead (for an arrow pointing straight up)
89
arrow_ends = ends - array(unit_vec * matrix([[a, a], [-a, a]])) * self.arrow_size
91
gc.line_set(ends, arrow_ends)
94
# Draw the left arrowhead (for an arrow pointing straight up)
95
arrow_ends = ends - array(unit_vec * matrix([[a, -a], [a, a]])) * self.arrow_size
97
gc.line_set(ends, arrow_ends)
73
gc.clip_to_rect(self.x, self.y, self.width, self.height)
75
gc.set_stroke_color(self.line_color_)
76
gc.set_line_width(self.line_width)
78
# Draw the body of the arrow
80
ends = points + self._cached_vector_data
82
gc.line_set(starts, ends)
85
if self.arrow_size > 0:
86
vec = self._cached_vector_data
87
unit_vec = vec / sqrt(vec[:,0] ** 2 + vec[:,1] ** 2)[:, newaxis]
88
a = 0.707106781 # sqrt(2)/2
90
# Draw the left arrowhead (for an arrow pointing straight up)
91
arrow_ends = ends - array(unit_vec * matrix([[a, a], [-a, a]])) * self.arrow_size
93
gc.line_set(ends, arrow_ends)
96
# Draw the left arrowhead (for an arrow pointing straight up)
97
arrow_ends = ends - array(unit_vec * matrix([[a, -a], [a, a]])) * self.arrow_size
99
gc.line_set(ends, arrow_ends)