MVariable

Qualified name: manim\_dsa.m\_variable.m\_variable.MVariable

class MVariable(value, style=<manim_dsa.constants.MVariableStyle._DefaultStyle object>)[source]

Bases: MElement, Labelable

Manim 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 to MVariableStyle.DEFAULT.

Methods

add_label

Adds a label to the variable, positioned relative to its elements.

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.

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 is UP.

  • 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 underlying add_label method.

Returns:

The instance of the MVariable with the added label.

Return type:

self