MArray#

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

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

Bases: VGroup

A class that represents an array.

Parameters:
  • scene (Scene) – Specifies the scene where the object is to be rendered.

  • arr (list, default: []) – Specifies the array to represent.

  • label (str, default: '') – Specifies the value of the array label.

  • index_offset (int, default: 1) – Specifies the difference between successive displayable indices.

  • index_start (int, default: 0) – Specifies the starting value of displayable index.

  • index_hex_display (bool, default: False) – If True, displays indices in hex.

  • hide_index (bool, default: False) – If True, doesn’t display indices.

  • arr_dir (MArrayDirection, default: <MArrayDirection.RIGHT: 2>) – Specifies the growth direction of the array.

  • arr_label_pos (MArrayDirection, default: <MArrayDirection.LEFT: 3>) – Specifies the position of __mob_arr_label w.r.t __mob_arr.

  • arr_label_gap (float, default: 0.5) – Specifies the distance between __mob_arr_label and __mob_arr.

  • mob_arr_label_args (dict, default: {}) – Arguments for Text that represents the array label.

  • mob_square_args (dict, default: {}) – Arguments for Square that represents the element body.

  • mob_value_args (dict, default: {'text': 3}) – Arguments for Text that represents the element value.

  • mob_index_args (dict, default: {'text': 2}) – Arguments for Text that represents the element index.

  • **kwargs – Forwarded to constructor of the parent.

__scene#

The scene where the object is to be rendered.

Type:

Scene

__arr#

The array to represent.

Type:

list

__label#

The value of the array label.

Type:

str

__index_offset#

The difference between successive displayable indices.

Type:

int

__index_start#

The starting value of displayable index.

Type:

int

__index_hex_display#

If True, displays indices in hex.

Type:

bool

__hide_index#

If True, doesn’t display indices.

Type:

bool

__arr_dir#

The growth direction of the array.

Type:

MArrayDirection

__arr_label_pos#

The position of __mob_arr_label w.r.t __mob_arr.

Type:

MArrayDirection

__arr_label_gap#

The distance between __mob_arr_label and __mob_arr.

Type:

float

__mob_arr_label_props#

Arguments for Text that represents the array label.

Type:

dict

__mob_arr#

Represents the array.

Type:

List[MArrayElement]

__mob_arr_label#

Represents the array label.

Type:

Text

Methods

animate_elem

Invokes the animate property over element mobject specified.

animate_elem_index

Invokes the animate property over index mobject of the specified element.

animate_elem_square

Invokes the animate property over square mobject of the specified element.

animate_elem_value

Invokes the animate property over value mobject of the specified element.

append_elem

Creates and inserts a new element in the array.

fetch_arr

Fetches the original array.

fetch_arr_dir

Fetches the growth direction enum of the array.

fetch_mob_arr

Fetches the mobject array.

fetch_mob_arr_label

Fetches the label mobject of the array.

remove_elem

Removes the element from the array at the specified index.

update_elem_index

Updates the elements index.

update_elem_value

Updates the elements value.

update_mob_arr_label

Updates the array label.

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)[source]#

Invokes the animate property over element mobject specified.

Parameters:

index (int) – Specifies the index of the element to animate.

Returns:

Animate property of MArrayElement.

Return type:

_AnimationBuilder

animate_elem_index(index)[source]#

Invokes the animate property over index mobject of the specified element.

Parameters:

index (int) – Specifies the index of the element who’s index mobject animate.

Returns:

Animate property of Text.

Return type:

_AnimationBuilder

animate_elem_square(index)[source]#

Invokes the animate property over square mobject of the specified element.

Parameters:

index (int) – Specifies the index of the element who’s square mobject to animate.

Returns:

Animate property of Square.

Return type:

_AnimationBuilder

animate_elem_value(index)[source]#

Invokes the animate property over value mobject of the specified element.

Parameters:

index (int) – Specifies the index of the element who’s value mobject animate.

Returns:

Animate property of Text.

Return type:

_AnimationBuilder

append_elem(value, append_anim=<class 'manim.animation.creation.Write'>, append_anim_args={}, append_anim_target=None, mob_square_args={}, mob_value_args={'text': 4}, mob_index_args={'text': 3}, play_anim=True, play_anim_args={})[source]#

Creates and inserts a new element in the array.

Parameters:
  • value (Any) – Specifies the value of the new element.

  • append_anim (Animation, default: <class 'manim.animation.creation.Write'>) – Animation to be applied to the new element.

  • append_anim_args (dict, default: {}) – Arguments for append Animation.

  • append_anim_target (Optional[MArrayElementComp], default: None) – Specifies the target Mobject of the MArrayElement on which the append Animation is to be played.

  • mob_square_args (dict, default: {}) – Arguments for Square that represents the element body.

  • mob_value_args (dict, default: {'text': 4}) – Arguments for Text that represents the element value.

  • mob_index_args (dict, default: {'text': 3}) – Arguments for Text that represents the element index.

  • play_anim (bool, default: True) – If True, plays the animation(s).

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

List of append animations.

Return type:

typing.List[Animation]

fetch_arr()[source]#

Fetches the original array.

Returns:

__arr.

Return type:

list

fetch_arr_dir()[source]#

Fetches the growth direction enum of the array.

Returns:

__arr_dir.

Return type:

MArrayDirection

fetch_mob_arr()[source]#

Fetches the mobject array.

Returns:

__mob_arr.

Return type:

List

fetch_mob_arr_label()[source]#

Fetches the label mobject of the array.

Returns:

__mob_arr_label.

Return type:

Text

remove_elem(index, removal_anim=<class 'manim.animation.fading.FadeOut'>, update_anim=<class 'manim.animation.indication.Indicate'>, removal_anim_args={}, update_anim_args={}, removal_anim_target=None, update_anim_target=MArrayElementComp.INDEX, play_anim=True, play_anim_args={})[source]#

Removes the element from the array at the specified index.

Parameters:
  • index (int) – Specifies the index of the element to remove.

  • removal_anim (Animation, default: <class 'manim.animation.fading.FadeOut'>) – Animation to be applied to the element being removed.

  • update_anim (Animation, default: <class 'manim.animation.indication.Indicate'>) – Animation to be applied on remaining elements.

  • removal_anim_args (dict, default: {}) – Arguments for removal Animation.

  • update_anim_args (dict, default: {}) – Arguments for update Animation.

  • removal_anim_target (Optional[MArrayElementComp], default: None) – Specifies the target Mobject of the MArrayElement on which the removal Animation is to be played.

  • update_anim_target (MArrayElementComp, default: <MArrayElementComp.INDEX: 2>) – Specifies the target Mobject of the MArrayElement on which the update Animation is to be played.

  • play_anim (bool, default: True) – If True, plays the animation(s).

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Return type:

Tuple[Succession, Callable[[bool], List[Animation]]]

Returns:

update_elem_index(index, value, mob_index_args={'text': -2}, update_anim=<class 'manim.animation.creation.Write'>, update_anim_args={}, play_anim=True, play_anim_args={})[source]#

Updates the elements index.

Parameters:
  • index (int) – Specifies the index of element whose index to update.

  • value – New value to be assigned to the index of the element.

  • mob_index_args (dict, default: {'text': -2}) – Arguments for Text that represents the element index.

  • update_anim (Animation, default: <class 'manim.animation.creation.Write'>) – Animation to be applied to the updated element.

  • update_anim_args (dict, default: {}) – Arguments for update Animation.

  • play_anim (bool, default: True) – If True, plays the animation(s).

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

Updated element’s index mobject.

Return type:

Text

update_elem_value(index, value, mob_value_args={'text': 20}, update_anim=<class 'manim.animation.creation.Write'>, update_anim_args={}, play_anim=True, play_anim_args={})[source]#

Updates the elements value.

Parameters:
  • index (int) – Specifies the index of element whose value to update.

  • value – New value to be assigned to the element.

  • mob_value_args (dict, default: {'text': 20}) – Arguments for Text that represents the element value.

  • update_anim (Animation, default: <class 'manim.animation.creation.Write'>) – Animation to be applied to the updated element.

  • update_anim_args (dict, default: {}) – Arguments for update Animation.

  • play_anim (bool, default: True) – If True, plays the animation(s).

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

Updated element’s value mobject.

Return type:

Text

update_mob_arr_label(label, mob_arr_label_args={}, update_anim=<class 'manim.animation.creation.Write'>, update_anim_args={}, play_anim=True, play_anim_args={})[source]#

Updates the array label.

Parameters:
  • label (str) – New value to be assigned to the array label.

  • mob_label_args – Arguments for Text that represents the array label.

  • update_anim (Animation, default: <class 'manim.animation.creation.Write'>) – Animation to be applied to the updated array label.

  • update_anim_args (dict, default: {}) – Arguments for update Animation.

  • play_anim (bool, default: True) – If True, plays the animation(s).

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

Updated __mob_arr_label.

Return type:

Text