MArray#

Qualified name: manim\_data\_structures.m\_array.MArray

class manim_data_structures.m_array.MArray(arr: list = [], label='', index_offset: int = 1, index_start: int = 0, index_hex_display: bool = False, hide_index: bool = False, arr_dir: MArrayDirection = MArrayDirection.RIGHT, switch_index_pos: bool = False, arr_label_pos: MArrayDirection = MArrayDirection.LEFT, arr_label_gap: float = 0.5, mob_arr_label_args: dict = {}, mob_square_args: dict = {}, mob_value_args: dict = {'text': 3}, mob_index_args: dict = {'text': 2}, **kwargs)#

Bases: VGroup

A class that represents an array.

Parameters#

arrlist, default: []

Array to represent. Elements must be convertible to str.

index_offsetint, default: 1

Difference between successive indices.

index_startint, default: 0

Starting value of index.

index_hex_displaybool, default: False

Displays indices in hex if True otherwise in decimal.

hide_indexbool, default: False

Specifies whether to display indices or not.

arr_dirm_enum.MArrayDirection, default: m_enum.MArrayDirection.RIGHT

Specifies the growing direction of array.

mob_square_argsdict, default: {}

Arguments for manim.Square that represents the element body of MArrayElement.

mob_value_argsdict, default: {}

Arguments for manim.Text that represents the element value of MArrayElement.

mob_index_argsdict, default: {}

Arguments for manim.Text that represents the element index of MArrayElement.

**kwargs

Forwarded to constructor of the parent.

Attributes#

__arrlist

Array to represent. Elements must be convertible to str.

__mob_arrList[MArrayElement]

Array containing the manim objects.

__index_offsetint

Difference between successive indices.

__index_startint

Starting value of index.

__index_hex_displaybool

Displays indices in hex if True otherwise in decimal.

__hide_indexbool, default: False

Specifies whether to display indices or not.

__arr_dirm_enum.MArrayDirection, default: m_enum.MArrayDirection.RIGHT

Specifies the growing direction of array.

__mob_arr_label_props

Methods

animate_elem

Invokes the MArrayElement.animate() property of MArrayElement on specified index of __mob_arr.

animate_elem_index

Invokes the manim.Text.animate() property of manim.Text on specified index of __mob_arr.

animate_elem_square

Invokes the manim.Square.animate() property of manim.Square on specified index of __mob_arr.

animate_elem_value

Invokes the manim.Text.animate() property of manim.Text on specified index of __mob_arr.

append_elem

Appends the value to __arr and creates a new MArrayElement and appends it to __mob_arr.

fetch_arr

Fetches __arr.

fetch_arr_label

Fetches the manim.Text that represents the array label.

fetch_mob_arr

Fetches __mob_arr.

remove_elem

Removes the element from __arr and removes MArrayElement from __mob_arr at the specified index.

update_elem_index

Updates the elements index.

update_elem_value

Updates the elements value.

Inherited Attributes

animate

Used to animate the application of any method of self.

color

depth

The depth of the mobject.

fill_color

If there are multiple colors (for gradient) this returns the first one

height

The height of the mobject.

n_points_per_curve

sheen_factor

stroke_color

width

The width of the mobject.

animate_elem(index: int) _AnimationBuilder#

Invokes the MArrayElement.animate() property of MArrayElement on specified index of __mob_arr.

Parameters#

indexint

Index of __mob_arr to animate.

Returns#

_AnimationBuilder

Value returned by MArrayElement.animate() property of MArrayElement.

animate_elem_index(index: int) _AnimationBuilder#

Invokes the manim.Text.animate() property of manim.Text on specified index of __mob_arr.

Parameters#

indexint

Index of __mob_arr to animate.

Returns#

_AnimationBuilder

Value returned by manim.Text.animate() property of manim.Text.

animate_elem_square(index: int) _AnimationBuilder#

Invokes the manim.Square.animate() property of manim.Square on specified index of __mob_arr.

Parameters#

indexint

Index of __mob_arr to animate.

Returns#

_AnimationBuilder

Value returned by manim.Square.animate() property of manim.Square.

animate_elem_value(index: int) _AnimationBuilder#

Invokes the manim.Text.animate() property of manim.Text on specified index of __mob_arr.

Parameters#

indexint

Index of __mob_arr to animate.

Returns#

_AnimationBuilder

Value returned by manim.Text.animate() property of manim.Text.

append_elem(value, append_anim: ~manim.animation.animation.Animation = <class 'manim.animation.creation.Write'>, append_anim_args: dict = {}, append_anim_target: ~typing.Optional[~manim_data_structures.m_enum.MArrayElementComp] = None, mob_square_args: dict = {}, mob_value_args: dict = {'text': 4}, mob_index_args: dict = {'text': 3}) List[Animation]#

Appends the value to __arr and creates a new MArrayElement and appends it to __mob_arr.

Parameters#

value

Value to append.

append_animmanim.Animation, default: manim.Write

Specifies the manim.Animation to be played on the MArrayElement being appended.

append_anim_argsdict, default: {}

Arguments for append manim.Animation.

append_anim_targetm_enum.MArrayElementComp, default: None

Specifies the manim.Mobject of the MArrayElement on which the append manim.Animation is to be played.

mob_square_argsdict, default: {}

Arguments for manim.Square that represents the element body of MArrayElement.

mob_value_argsdict, default: {}

Arguments for manim.Text that represents the element value of MArrayElement.

mob_index_argsdict, default: {}

Arguments for manim.Text that represents the element index of MArrayElement.

shift_label: bool, default: True

Specifies whether to shift the __mob_arr_label or not.

Returns#

List[manim.Animation]

List of animations for appending.

fetch_arr() list#

Fetches __arr.

Returns#

list

Represents the array stored in __arr.

fetch_arr_label() Text#

Fetches the manim.Text that represents the array label.

Returns#

manim.Text

Represents the array label.

fetch_mob_arr() List[MArrayElement]#

Fetches __mob_arr.

Returns#

List[MArrayElement]

Represents the array stored in __mob_arr.

remove_elem(index, removal_anim: ~manim.animation.animation.Animation = <class 'manim.animation.fading.FadeOut'>, update_anim: ~manim.animation.animation.Animation = <class 'manim.animation.creation.Write'>, removal_anim_args: dict = {}, update_anim_args: dict = {}, removal_anim_target: ~typing.Optional[~manim_data_structures.m_enum.MArrayElementComp] = None, update_anim_target: ~manim_data_structures.m_enum.MArrayElementComp = MArrayElementComp.INDEX) Tuple[Succession, Callable[[], List[Animation]]]#

Removes the element from __arr and removes MArrayElement from __mob_arr at the specified index.

Parameters#

indexint

Index of MArrayElement to remove.

removal_animmanim.Animation, default: manim.FadeOut

Specifies the manim.Animation to be played on the MArrayElement being removed.

update_animmanim.Animation, default: manim.Write

Specifies the manim.Animation to be played on the :class:`MArrayElement`(s) after the removed element.

removal_anim_argsdict, default: {}

Arguments for removal manim.Animation.

update_anim_argsdict, default: {}

Arguments for update manim.Animation.

removal_anim_targetm_enum.MArrayElementComp, default: None

Specifies the manim.Mobject of the MArrayElement on which the removal manim.Animation is to be played.

update_anim_targetm_enum.MArrayElementComp, default: m_enum.MArrayElementComp.INDEX

Specifies the manim.Mobject of the MArrayElement on which the update manim.Animation is to be played.

Returns#

manim.Succession

Contains manim.Animations played for removal and shifting of MArrayElement.

Callable[[], List[manim.Animation]]

Method that updates the indices of :class:`MArrayElement`(s) that occur after the removal and returns a list of update :class:`manim.Animation`(s).

update_elem_index(index: int, value, mob_index_args: dict = {'text': -2}) Text#

Updates the elements index.

Parameters#

indexint

Index of __mob_arr to update.

value

New value to be assigned.

mob_index_argsdict, default: {}

Arguments for manim.Text that represents the element index of MArrayElement.

Returns#

manim.Text

Represents the updated element index.

update_elem_value(index: int, value, mob_value_args: dict = {'text': 20}) Text#

Updates the elements value.

Parameters#

indexint

Index of __mob_arr to update.

value

New value to be assigned.

mob_value_argsdict, default: {}

Arguments for manim.Text that represents the element value of MArrayElement.

Returns#

manim.Text

Represents the updated element value.