MVariable¶
Qualified name: manim\_dsa.m\_variable.m\_variable.MVariable
- class MVariable(value, style=<manim_dsa.constants.MVariableStyle._DefaultStyle object>)[source]¶
Bases:
MElement,LabelableManim Variable: a class for visualizing a variable using the Manim animation engine.
- Parameters:
value (Any) – The initial value of the variable to be displayed.
style (
MVariableStyle._DefaultStyle, optional) – The style configuration to be applied to the variable. Defaults toMVariableStyle.DEFAULT.
Methods
Adds a label to the variable, positioned relative to its elements.
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 variable, positioned relative to its elements.
- Parameters:
text (
Text) – The text label to be added.direction (
Vector3D, optional) – The direction in which to position the label. Default isUP.buff (float, optional) – The buffer distance between the label and the element. 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
MVariablewith the added label.- Return type:
self