manim.mobject.geometry.Arrow

class Arrow(*args, stroke_width=6, buff=0.25, max_tip_length_to_length_ratio=0.25, max_stroke_width_to_length_ratio=5, preserve_tip_size_when_scaling=True, **kwargs)[source]

Bases: manim.mobject.geometry.Line

An arrow.

Parameters
  • args (Any) – Arguments to be passed to Line.

  • stroke_width (float, optional) – The thickness of the arrow. Influenced by max_stroke_width_to_length_ratio.

  • buff (float, optional) – The distance of the arrow from its start and end points.

  • max_tip_length_to_length_ratio (float, optional) – tip_length scales with the length of the arrow. Increasing this ratio raises the max value of tip_length.

  • max_stroke_width_to_length_ratio (float, optional) – stroke_width scales with the length of the arrow. Increasing this ratio ratios the max value of stroke_width.

  • preserve_tip_size_when_scaling (bool, optional) – No purpose.

  • kwargs (Any) – Additional arguments to be passed to Line.

Examples

../_images/ArrowExample-1.png
ArrowExample
from manim.mobject.geometry import ArrowSquareTip
class ArrowExample(Scene):
    def construct(self):
        arrow_1 = Arrow(start=RIGHT, end=LEFT, color=GOLD)
        arrow_2 = Arrow(start=RIGHT, end=LEFT, color=GOLD, tip_shape=ArrowSquareTip).shift(DOWN)
        g1 = Group(arrow_1, arrow_2)

        # the effect of buff
        square = Square(color=MAROON_A)
        arrow_3 = Arrow(start=LEFT, end=RIGHT)
        arrow_4 = Arrow(start=LEFT, end=RIGHT, buff=0).next_to(arrow_1, UP)
        g2 = Group(arrow_3, arrow_4, square)

        # a shorter arrow has a shorter tip and smaller stroke width
        arrow_5 = Arrow(start=ORIGIN, end=config.top).shift(LEFT * 4)
        arrow_6 = Arrow(start=config.top + DOWN, end=config.top).shift(LEFT * 3)
        g3 = Group(arrow_5, arrow_6)

        self.add(Group(g1, g2, g3).arrange(buff=2))

See also

ArrowTip, CurvedArrow

Methods

get_default_tip_length

Returns the default tip_length of the arrow.

get_normal_vector

Returns the normal of a vector.

reset_normal_vector

Resets the normal of a vector

scale

Scale an arrow, but keep stroke width and arrow tip size fixed.

set_stroke_width_from_length

Used internally.

Attributes

animate

Used to animate the application of a method.

depth

The depth of the mobject.

height

The height of the mobject.

width

The width of the mobject.

get_default_tip_length()[source]

Returns the default tip_length of the arrow.

Examples

>>> Arrow().get_default_tip_length()
0.35
Return type

float

get_normal_vector()[source]

Returns the normal of a vector.

Examples

>>> Arrow().get_normal_vector() + 0. # add 0. to avoid negative 0 in output
array([ 0.,  0., -1.])
Return type

numpy.ndarray

reset_normal_vector()[source]

Resets the normal of a vector

scale(factor, scale_tips=False, **kwargs)[source]

Scale an arrow, but keep stroke width and arrow tip size fixed.

See also

scale()

Examples

>>> arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0)
>>> scaled_arrow = arrow.scale(2)
>>> scaled_arrow.get_start_and_end()
(array([-2., -2.,  0.]), array([2., 2., 0.]))
>>> arrow.tip.length == scaled_arrow.tip.length
True

Manually scaling the object using the default method scale() does not have the same properties:

>>> new_arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0)
>>> another_scaled_arrow = VMobject.scale(new_arrow, 2)
>>> another_scaled_arrow.tip.length == arrow.tip.length
False
set_stroke_width_from_length()[source]

Used internally. Sets stroke width based on length.