MVariable#

Qualified name: manim\_data\_structures.m\_variable.MVariable

class MVariable(scene, value='', index='', label='', mob_square_args={}, mob_value_args={'text': 10}, mob_index_args={'text': 0}, mob_label_args={'text': 'Var'}, **kwargs)[source]#

Bases: MArrayElement

A class that represents a variable.

Parameters:
  • scene (Scene) – Specifies the scene where the object is to be rendered.

  • value (Any, default: '') – Specifies the value of the variable.

  • index (Union[str, int], default: '') – Specifies the index of the variable.

  • label (str, default: '') – Specifies the label of the variable.

  • mob_square_args (dict, default: {}) – Arguments for Square that represents the variable body.

  • mob_value_args (dict, default: {'text': 10}) – Arguments for Text that represents the variable value.

  • mob_index_args (dict, default: {'text': 0}) – Arguments for Text that represents the variable index.

  • mob_label_args (dict, default: {'text': 'Var'}) – Arguments for Text that represents the variable label.

  • **kwargs – Forwarded to constructor of the parent.

__value#

The value of the variable.

Type:

Any

__index#

The value of the index.

Type:

Union[str, int]

__label#

The value of the label.

Type:

str

Methods

fetch_index

Fetches the index of the variable.

fetch_label

Fetches the label of the variable.

fetch_value

Fetches the value of the variable.

update_index

Updates the index of the variable.

update_label

Updates the label of the variable.

update_value

Updates the value of the variable.

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.

fetch_index()[source]#

Fetches the index of the variable.

Returns:

__index.

Return type:

Union[str, int]

fetch_label()[source]#

Fetches the label of the variable.

Returns:

__label.

Return type:

str

fetch_value()[source]#

Fetches the value of the variable.

Returns:

__value.

Return type:

Any

update_index(index, mob_index_args={}, update_anim=<class 'manim.animation.indication.Indicate'>, update_anim_args={}, play_anim=True, play_anim_args={})[source]#

Updates the index of the variable.

Parameters:
  • index (Union[str, int]) – New index to be assigned to the variable.

  • mob_index_args (dict, default: {}) – Arguments for Text that represents the variable index.

  • update_anim (Animation, default: <class 'manim.animation.indication.Indicate'>) – Animation to be applied to the updated Text.

  • update_anim_args (dict, default: {}) – Arguments for the update Animation.

  • play_anim (bool, default: True) – Specifies whether to play the Animation.

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

Updated __index.

Return type:

Text

update_label(label, mob_label_args={}, update_anim=<class 'manim.animation.indication.Indicate'>, update_anim_args={}, play_anim=True, play_anim_args={})[source]#

Updates the label of the variable.

Parameters:
  • label (str) – New label to be assigned to the variable.

  • mob_value_args – Arguments for Text that represents the label value.

  • update_anim (Animation, default: <class 'manim.animation.indication.Indicate'>) – Animation to be applied to the updated Text.

  • update_anim_args (dict, default: {}) – Arguments for the update Animation.

  • play_anim (bool, default: True) – Specifies whether to play the Animation.

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

Updated __label.

Return type:

Text

update_value(value, mob_value_args={'text': 24}, update_anim=<class 'manim.animation.indication.Indicate'>, update_anim_args={}, play_anim=True, play_anim_args={})[source]#

Updates the value of the variable.

Parameters:
  • value (Any) – New value to be assigned to the variable.

  • mob_value_args (dict, default: {'text': 24}) – Arguments for Text that represents the variable value.

  • update_anim (Animation, default: <class 'manim.animation.indication.Indicate'>) – Animation to be applied to the updated Text.

  • update_anim_args (dict, default: {}) – Arguments for the update Animation.

  • play_anim (bool, default: True) – Specifies whether to play the Animation.

  • play_anim_args (dict, default: {}) – Arguments for Scene.play().

Returns:

Updated __value.

Return type:

Text