MArraySlidingWindow#

Qualified name: manim\_data\_structures.m\_array.MArraySlidingWindow

class MArraySlidingWindow(scene, arr, index=0, size=1, label='', label_gap=0.5, label_pos=MArrayDirection.DOWN, mob_window_args={}, mob_label_args={}, **kwargs)[source]#

Bases: VGroup

A class that represents a sliding window

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

  • arr (MArray) – Specifies the array to which the sliding window is to be attached.

  • index (int, default: 0) – Specifies the index of the element to which the sliding window is to be attached.

  • size (int, default: 1) – Specifies the number of elements the sliding window should enclose.

  • label (str, default: '') – Specifies the value of the sliding window label.

  • label_gap (float, default: 0.5) – Specifies the distance between __mob_label and __mob_window.

  • label_pos (MArrayDirection, default: <MArrayDirection.DOWN: 1>) – Specifies the position of the pointer w.r.t to __mob_window.

  • mob_window_args (dict, default: {}) – Arguments for Rectangle that represents the window.

  • mob_label_args (dict, default: {}) – Arguments for Text that represents the window label.

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

__scene#

The scene where the object is to be rendered.

Type:

Scene

__arr#

The array to which the sliding window is to be attached.

Type:

List[MArrayElement]

__index#

The index of the element to which the sliding window is to be attached.

Type:

int

__size#

The number of elements the sliding window should enclose.

Type:

int

__label#

The value of the sliding window label.

Type:

str

__label_gap#

The distance between __mob_label and __mob_window.

Type:

float

__label_pos#

The position of the pointer w.r.t to __mob_window.

Type:

m_enum.MArrayDirection

__mob_window_props#

Arguments for Rectangle that represents the window.

Type:

dict

__mob_label_props#

Arguments for Text that represents the window label.

Type:

dict

__mob_window#

Represents the window of the sliding window.

Type:

Rectangle

__mob_label#

Represents the label of the sliding window.

Type:

Text

__updater_pos#

The updater function that keeps the sliding window intact with the array.

Type:

typing.Callable[[], None]

Methods

animate_mob_label

Invokes the animate property over label mobject.

animate_mob_window

Invokes the animate property over window mobject.

attach_to_elem

Attaches pointer to the specified element.

fetch_mob_label

Fetches the label mobject of the sliding window.

fetch_mob_window

Fetches the window mobject of the sliding window.

resize_window

Expands or shrinks the window according to the specified size.

shift_to_elem

Shifts sliding window to the specified element.

update_mob_label

Updates the window label.

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.

animate_mob_label()[source]#

Invokes the animate property over label mobject.

Returns:

Animate property of __mob_label.

Return type:

_AnimationBuilder

animate_mob_window()[source]#

Invokes the animate property over window mobject.

Returns:

Animate property of __mob_window.

Return type:

_AnimationBuilder

attach_to_elem(index)[source]#

Attaches pointer to the specified element.

Parameters:

index (int) – Specifies the index of the element to which the sliding window is to be attached.

Return type:

None

fetch_mob_label()[source]#

Fetches the label mobject of the sliding window.

Returns:

__mob_label.

Return type:

Text

fetch_mob_window()[source]#

Fetches the window mobject of the sliding window.

Returns:

__mob_window.

Return type:

Rectangle

resize_window(size, play_anim=True, play_anim_args={})[source]#

Expands or shrinks the window according to the specified size.

Parameters:
  • size (int) – Specifies the number of elements the sliding window should enclose.

  • play_anim (bool, default: True) – If True, plays the animation(s).

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

Returns:

Resize animation.

Return type:

ApplyFunction

shift_to_elem(index, play_anim=True, play_anim_args={})[source]#

Shifts sliding window to the specified element.

Parameters:
  • index (int) – Specifies the index of the element to which the sliding window is to be shifted.

  • play_anim (bool, default: True) – If True, plays the animation(s).

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

Returns:

Shift animation.

Return type:

ApplyFunction

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

Updates the window label.

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

  • mob_label_args (dict, default: {}) – Arguments for Text that represents the window label.

  • update_anim (Animation, default: <class 'manim.animation.creation.Write'>) – Animation to be applied to the updated window label.

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

  • play_anim (bool, default: True) – If True, plays the animation(s).

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

Returns:

Updated __mob_label.

Return type:

Text