Skip to content

Commit e8d076c

Browse files
committed
add convenience classes for filled/empty arrow tips
1 parent 151d0a3 commit e8d076c

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

manim/mobject/geometry.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TipableVMobject(VMobject):
5151
"tip_length": DEFAULT_ARROW_TIP_LENGTH,
5252
# TODO
5353
"normal_vector": OUT,
54-
"tip_style": {"fill_opacity": 1, "stroke_width": 0,},
54+
"tip_style": dict(),
5555
}
5656

5757
# Adding, Creating, Modifying tips
@@ -83,7 +83,7 @@ def get_unpositioned_tip(self, tip_shape=None, tip_length=None):
8383
but has not yet been given a position in space.
8484
"""
8585
if tip_shape is None:
86-
tip_shape = ArrowTriangleTip
86+
tip_shape = ArrowTriangleFilledTip
8787
if tip_length is None:
8888
tip_length = self.get_default_tip_length()
8989
color = self.get_color()
@@ -308,7 +308,7 @@ def __init__(self, start, end, angle=TAU / 4, radius=None, **kwargs):
308308
class CurvedArrow(ArcBetweenPoints):
309309
def __init__(self, start_point, end_point, **kwargs):
310310
ArcBetweenPoints.__init__(self, start_point, end_point, **kwargs)
311-
self.add_tip(tip_shape=kwargs.get("tip_shape", ArrowTriangleTip))
311+
self.add_tip(tip_shape=kwargs.get("tip_shape", ArrowTriangleFilledTip))
312312

313313

314314
class CurvedDoubleArrow(CurvedArrow):
@@ -317,7 +317,7 @@ def __init__(self, start_point, end_point, **kwargs):
317317
kwargs["tip_shape"] = kwargs.pop("tip_shape_end")
318318
CurvedArrow.__init__(self, start_point, end_point, **kwargs)
319319
self.add_tip(at_start=True,
320-
tip_shape=kwargs.get("tip_shape_start", ArrowTriangleTip))
320+
tip_shape=kwargs.get("tip_shape_start", ArrowTriangleFilledTip))
321321

322322

323323
class Circle(Arc):
@@ -607,7 +607,7 @@ def __init__(self, *args, **kwargs):
607607
# TODO, should this be affected when
608608
# Arrow.set_stroke is called?
609609
self.initial_stroke_width = self.stroke_width
610-
self.add_tip(tip_shape=kwargs.get("tip_shape", ArrowTriangleTip))
610+
self.add_tip(tip_shape=kwargs.get("tip_shape", ArrowTriangleFilledTip))
611611
self.set_stroke_width_from_length()
612612

613613
def scale(self, factor, **kwargs):
@@ -675,7 +675,7 @@ def __init__(self, *args, **kwargs):
675675
kwargs["tip_shape"] = kwargs.pop("tip_shape_end")
676676
Arrow.__init__(self, *args, **kwargs)
677677
self.add_tip(at_start=True,
678-
tip_shape=kwargs.get("tip_shape_start", ArrowTriangleTip))
678+
tip_shape=kwargs.get("tip_shape_start", ArrowTriangleFilledTip))
679679

680680

681681
class CubicBezier(VMobject):
@@ -793,7 +793,7 @@ def __init__(self, **kwargs):
793793
class ArrowTip(VMobject):
794794
CONFIG = {
795795
"fill_opacity": 0,
796-
"stroke_width": 0,
796+
"stroke_width": 3,
797797
"length": DEFAULT_ARROW_TIP_LENGTH,
798798
"start_angle": PI,
799799
}
@@ -818,6 +818,15 @@ def tip_angle(self):
818818
return angle_of_vector(self.vector)
819819

820820

821+
class ArrowFilledTip(ArrowTip):
822+
CONFIG = {
823+
"fill_opacity": 1,
824+
"stroke_width": 0,
825+
"length": DEFAULT_ARROW_TIP_LENGTH,
826+
"start_angle": PI,
827+
}
828+
829+
821830
class ArrowTriangleTip(ArrowTip, Triangle):
822831
def __init__(self, **kwargs):
823832
digest_config(self, kwargs)
@@ -826,6 +835,10 @@ def __init__(self, **kwargs):
826835
self.set_height(self.length, stretch=True)
827836

828837

838+
class ArrowTriangleFilledTip(ArrowFilledTip, ArrowTriangleTip):
839+
pass
840+
841+
829842
class ArrowCircleTip(ArrowTip, Circle):
830843
def __init__(self, **kwargs):
831844
digest_config(self, kwargs)
@@ -834,9 +847,17 @@ def __init__(self, **kwargs):
834847
self.set_height(self.length, stretch=True)
835848

836849

850+
class ArrowCircleFilledTip(ArrowFilledTip, ArrowCircleTip):
851+
pass
852+
853+
837854
class ArrowSquareTip(ArrowTip, Square):
838855
def __init__(self, **kwargs):
839856
digest_config(self, kwargs)
840857
Square.__init__(self, side_length=self.length, **kwargs)
841858
self.set_width(self.length)
842859
self.set_height(self.length, stretch=True)
860+
861+
862+
class ArrowSquareFilledTip(ArrowFilledTip, ArrowSquareTip):
863+
pass

0 commit comments

Comments
 (0)