MArray¶
Qualified name: manim\_dsa.m\_collection.m\_array.MArray
- class MArray(arr=[], direction=array([1., 0., 0.]), style=<manim_dsa.constants.MArrayStyle._DefaultStyle object>)[source]¶
Bases:
MCollectionManim Array: a class for visualizing the array data structure using the Manim animation engine.
- Parameters:
arr (list, optional) – The initial list of values to populate the array. Default is an empty list.
direction (
Vector3D, optional) – The direction in which to arrange the elements. Default isRIGHT.margin (float, optional) – The margin between elements in the array. Default is 0.
style (
MArrayStyle._DefaultStyle, optional) – The style configuration for the elements. Default isMArrayStyle.DEFAULT.
Methods
Adds indexes to each element in the array, displaying them in the specified direction.
Appends a new element to the end of the array.
Removes the element at the specified index and shifts all subsequent elements accordingly.
Inherited Attributes
animateUsed to animate the application of any method of
self.colordepthThe depth of the mobject.
fill_colorIf there are multiple colors (for gradient) this returns the first one
heightThe height of the mobject.
n_points_per_curvesheen_factorstroke_colorwidthThe width of the mobject.
- add_indexes(direction=array([0., 1., 0.]), buff=0.25)[source]¶
Adds indexes to each element in the array, displaying them in the specified direction.
- Parameters:
- Returns:
The instance of the
MArraywith the indices added to each element.- Return type:
self
- Raises:
Exception – If the specified direction is parallel to the array’s growth direction.
Notes
If indices are already enabled, this method returns immediately without making any changes.
- append(value)[source]¶
Appends a new element to the end of the array. If indexing is enabled, the new element will also be assigned an index based on its position in the array.
- Parameters:
value (Any) – The value to append. It will be converted to a string representation.
- Returns:
The instance of the
MArraywith the newly appended element.- Return type:
self