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 forText
that represents the array label.mob_square_args (
dict
, default:{}
) – Arguments forSquare
that represents the element body.mob_value_args (
dict
, default:{'text': 3}
) – Arguments forText
that represents the element value.mob_index_args (
dict
, default:{'text': 2}
) – Arguments forText
that represents the element index.**kwargs – Forwarded to constructor of the parent.
- __arr_dir#
The growth direction of the array.
- Type:
- __arr_label_pos#
The position of
__mob_arr_label
w.r.t__mob_arr
.- Type:
- __arr_label_gap#
The distance between
__mob_arr_label
and__mob_arr
.- Type:
- __mob_arr#
Represents the array.
- Type:
Methods
Invokes the animate property over element mobject specified.
Invokes the animate property over index mobject of the specified element.
Invokes the animate property over square mobject of the specified element.
Invokes the animate property over value mobject of the specified element.
Creates and inserts a new element in the array.
Fetches the original array.
Fetches the growth direction enum of the array.
Fetches the mobject array.
Fetches the label mobject of the array.
Removes the element from the array at the specified index.
Updates the elements index.
Updates the elements value.
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.
- animate_elem_square(index)[source]#
Invokes the animate property over square mobject of the specified element.
- animate_elem_value(index)[source]#
Invokes the animate property over value mobject of the specified element.
- 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 appendAnimation
.append_anim_target (
Optional
[MArrayElementComp
], default:None
) – Specifies the targetMobject
of theMArrayElement
on which the appendAnimation
is to be played.mob_square_args (
dict
, default:{}
) – Arguments forSquare
that represents the element body.mob_value_args (
dict
, default:{'text': 4}
) – Arguments forText
that represents the element value.mob_index_args (
dict
, default:{'text': 3}
) – Arguments forText
that represents the element index.play_anim (
bool
, default:True
) – If True, plays the animation(s).play_anim_args (
dict
, default:{}
) – Arguments forScene.play()
.
- Returns:
List of append animations.
- Return type:
- 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 removalAnimation
.update_anim_args (
dict
, default:{}
) – Arguments for updateAnimation
.removal_anim_target (
Optional
[MArrayElementComp
], default:None
) – Specifies the targetMobject
of theMArrayElement
on which the removalAnimation
is to be played.update_anim_target (
MArrayElementComp
, default:<MArrayElementComp.INDEX: 2>
) – Specifies the targetMobject
of theMArrayElement
on which the updateAnimation
is to be played.play_anim (
bool
, default:True
) – If True, plays the animation(s).play_anim_args (
dict
, default:{}
) – Arguments forScene.play()
.
- Return type:
- 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 forText
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 updateAnimation
.play_anim (
bool
, default:True
) – If True, plays the animation(s).play_anim_args (
dict
, default:{}
) – Arguments forScene.play()
.
- Returns:
Updated element’s index mobject.
- Return type:
- 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 forText
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 updateAnimation
.play_anim (
bool
, default:True
) – If True, plays the animation(s).play_anim_args (
dict
, default:{}
) – Arguments forScene.play()
.
- Returns:
Updated element’s value mobject.
- Return type:
- 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 updateAnimation
.play_anim (
bool
, default:True
) – If True, plays the animation(s).play_anim_args (
dict
, default:{}
) – Arguments forScene.play()
.
- Returns:
Updated
__mob_arr_label
.- Return type: