MStack¶
Qualified name: manim\_dsa.m\_collection.m\_stack.MStack
- class MStack(arr=[], buff=0.1, style=<manim_dsa.constants.MStackStyle._DefaultStyle object>)[source]¶
Bases:
MCollectionManim Stack: a class for visualizing the stack data structure using the Manim animation engine.
- Parameters:
arr (list, optional) – The initial list of values to populate the stack. Default is an empty list.
buff (float, optional) – The buffer (margin) between elements in the stack. Default is
0.1.style (
MStackStyle._DefaultStyle, optional) – The style configuration for the stack elements. Default isMStackStyle.DEFAULT.
Methods
Adds a label to the stack.
Appends a new value to the top of the stack.
Calculates the drop point for new elements in the stack.
Removes the top element from the stack.
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_label(text, direction=array([0., 1., 0.]), buff=0.5, **kwargs)[source]¶
Adds a label to the stack.
- Parameters:
text (
Text) – The label text.direction (
Vector3D, optional) – The direction in which to position the label. Default isUP.buff (float, optional) – The distance (buffer) between the stack and the label. Default is 0.5.
**kwargs – Additional keyword arguments that are passed to the
next_to()method of the underlyingadd_labelmethod.
- Returns:
The instance of the
MStackwith the label added.- Return type:
self
- append(value)[source]¶
Appends a new value to the top of the stack.
- Parameters:
value (Any) – The value to be added to the stack. It will be converted to a string representation.
- Returns:
The instance of the
MStackwith the newly appended element.- Return type:
self