From c7f92d53cd34a8ca15f2d97c8c6c208137b14f78 Mon Sep 17 00:00:00 2001 From: Ben Hambrecht Date: Mon, 22 Jan 2018 16:30:07 -0800 Subject: [PATCH] Arcs can now have arrows on both sides --- topics/geometry.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/topics/geometry.py b/topics/geometry.py index 73318cc7..a91d23e7 100644 --- a/topics/geometry.py +++ b/topics/geometry.py @@ -36,18 +36,32 @@ class Arc(VMobject): ) self.scale(self.radius, about_point = ORIGIN) - def add_tip(self, tip_length = 0.25, end = 0): + def add_tip(self, tip_length = 0.25, at_start = False, at_end = True): #TODO, do this a better way - if end == 1: + p1 = p2 = p3 = p4 = None + start_arrow = end_arrow = None + if at_start: p1, p2 = self.points[-2:] - else: - p2, p1 = self.points[:2] - arrow = Arrow( - p1, 2*p2 - p1, - tip_length = tip_length, - max_tip_length_to_length_ratio = 2.0 - ) - self.add(arrow.split()[-1]) + start_arrow = Arrow( + p1, 2*p2 - p1, + tip_length = tip_length, + max_tip_length_to_length_ratio = 2.0 + ) + self.add(start_arrow.split()[-1]) + + if at_end: + p4, p3 = self.points[:2] + end_arrow = Arrow( + p3, 2*p4 - p3, + tip_length = tip_length, + max_tip_length_to_length_ratio = 2.0 + ) + self.add(end_arrow.split()[-1]) + + + + + self.highlight(self.get_color()) return self