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#
- arr
list
, default: [] Array to represent. Elements must be convertible to
str
.- index_offset
int
, default: 1 Difference between successive indices.
- index_start
int
, default: 0 Starting value of index.
- index_hex_display
bool
, default: False Displays indices in hex if True otherwise in decimal.
- hide_index
bool
, default: False Specifies whether to display indices or not.
- arr_dir
m_enum.MArrayDirection
, default:m_enum.MArrayDirection.RIGHT
Specifies the growing direction of array.
- mob_square_args
dict
, default: {} Arguments for
manim.Square
that represents the element body ofMArrayElement
.- mob_value_args
dict
, default: {} Arguments for
manim.Text
that represents the element value ofMArrayElement
.- mob_index_args
dict
, default: {} Arguments for
manim.Text
that represents the element index ofMArrayElement
.- **kwargs
Forwarded to constructor of the parent.
Attributes#
- __arr
list
Array to represent. Elements must be convertible to
str
.- __mob_arrList[
MArrayElement
] Array containing the manim objects.
- __index_offset
int
Difference between successive indices.
- __index_start
int
Starting value of index.
- __index_hex_display
bool
Displays indices in hex if True otherwise in decimal.
- __hide_index
bool
, default: False Specifies whether to display indices or not.
- __arr_dir
m_enum.MArrayDirection
, default:m_enum.MArrayDirection.RIGHT
Specifies the growing direction of array.
__mob_arr_label_props
Methods
Invokes the
MArrayElement.animate()
property ofMArrayElement
on specified index of__mob_arr
.Invokes the
manim.Text.animate()
property ofmanim.Text
on specified index of__mob_arr
.Invokes the
manim.Square.animate()
property ofmanim.Square
on specified index of__mob_arr
.Invokes the
manim.Text.animate()
property ofmanim.Text
on specified index of__mob_arr
.Appends the value to
__arr
and creates a newMArrayElement
and appends it to__mob_arr
.Fetches
__arr
.Fetches the
manim.Text
that represents the array label.Fetches
__mob_arr
.Removes the element from
__arr
and removesMArrayElement
from__mob_arr
at the specified index.Updates the elements index.
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 ofMArrayElement
on specified index of__mob_arr
.Parameters#
- index
int
Index of
__mob_arr
to animate.
Returns#
_AnimationBuilder
Value returned by
MArrayElement.animate()
property ofMArrayElement
.
- index
- animate_elem_index(index: int) _AnimationBuilder #
Invokes the
manim.Text.animate()
property ofmanim.Text
on specified index of__mob_arr
.Parameters#
- index
int
Index of
__mob_arr
to animate.
Returns#
_AnimationBuilder
Value returned by
manim.Text.animate()
property ofmanim.Text
.
- index
- animate_elem_square(index: int) _AnimationBuilder #
Invokes the
manim.Square.animate()
property ofmanim.Square
on specified index of__mob_arr
.Parameters#
- index
int
Index of
__mob_arr
to animate.
Returns#
_AnimationBuilder
Value returned by
manim.Square.animate()
property ofmanim.Square
.
- index
- animate_elem_value(index: int) _AnimationBuilder #
Invokes the
manim.Text.animate()
property ofmanim.Text
on specified index of__mob_arr
.Parameters#
- index
int
Index of
__mob_arr
to animate.
Returns#
_AnimationBuilder
Value returned by
manim.Text.animate()
property ofmanim.Text
.
- index
- 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 newMArrayElement
and appends it to__mob_arr
.Parameters#
- value
Value to append.
- append_anim
manim.Animation
, default:manim.Write
Specifies the
manim.Animation
to be played on theMArrayElement
being appended.- append_anim_args
dict
, default: {} Arguments for append
manim.Animation
.- append_anim_target
m_enum.MArrayElementComp
, default: None Specifies the
manim.Mobject
of theMArrayElement
on which the appendmanim.Animation
is to be played.- mob_square_args
dict
, default: {} Arguments for
manim.Square
that represents the element body ofMArrayElement
.- mob_value_args
dict
, default: {} Arguments for
manim.Text
that represents the element value ofMArrayElement
.- mob_index_args
dict
, default: {} Arguments for
manim.Text
that represents the element index ofMArrayElement
.- 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_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
.
- List[
- 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 removesMArrayElement
from__mob_arr
at the specified index.Parameters#
- index
int
Index of
MArrayElement
to remove.- removal_anim
manim.Animation
, default:manim.FadeOut
Specifies the
manim.Animation
to be played on theMArrayElement
being removed.- update_anim
manim.Animation
, default:manim.Write
Specifies the
manim.Animation
to be played on the :class:`MArrayElement`(s) after the removed element.- removal_anim_args
dict
, default: {} Arguments for removal
manim.Animation
.- update_anim_args
dict
, default: {} Arguments for update
manim.Animation
.- removal_anim_target
m_enum.MArrayElementComp
, default: None Specifies the
manim.Mobject
of theMArrayElement
on which the removalmanim.Animation
is to be played.- update_anim_target
m_enum.MArrayElementComp
, default:m_enum.MArrayElementComp.INDEX
Specifies the
manim.Mobject
of theMArrayElement
on which the updatemanim.Animation
is to be played.
Returns#
manim.Succession
Contains
manim.Animations
played for removal and shifting ofMArrayElement
.- 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).
- index
- update_elem_index(index: int, value, mob_index_args: dict = {'text': -2}) Text #
Updates the elements index.
Parameters#
- index
int
Index of
__mob_arr
to update.- value
New value to be assigned.
- mob_index_args
dict
, default: {} Arguments for
manim.Text
that represents the element index ofMArrayElement
.
Returns#
manim.Text
Represents the updated element index.
- index
- update_elem_value(index: int, value, mob_value_args: dict = {'text': 20}) Text #
Updates the elements value.
Parameters#
- index
int
Index of
__mob_arr
to update.- value
New value to be assigned.
- mob_value_args
dict
, default: {} Arguments for
manim.Text
that represents the element value ofMArrayElement
.
Returns#
manim.Text
Represents the updated element value.
- index
- arr