You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: updated MArray & MArrayElement + added MVariable
* Added remove element function in MArray
* Added label support in MArrayElement
* Added generic mob fetch function in MArrayElement coupled with MArrayElementComp enum
* Changed array.py to m_array.py because of conflict with native array module
* Added variables documentation in references
* Updated module name of m_array in references
* feat: MArray label added
* Label with four different direcitons added.
* Label shifts on append and remove element appropriately.
* Update label text doesn't remove previous label, therefore not added in this commit.
* Method to fetch array label.
* add: updated docs for new features
* release: 0.1.5
Copy file name to clipboardExpand all lines: docs/source/guides/arrays.rst
+177-7Lines changed: 177 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
Animating Arrays
2
2
================
3
3
4
-
.. currentmodule:: manim_data_structures.array
4
+
.. currentmodule:: manim_data_structures.m_array
5
5
6
6
Manim Array - MArray
7
7
--------------------
@@ -39,6 +39,7 @@ Animating MArray
39
39
To animate the :py:class:`MArray`, simply invoke the ``animate`` property as shown below:
40
40
41
41
.. code-block:: python
42
+
:linenos:
42
43
43
44
self.play(arr.animate.shift(UP*2+LEFT*5))
44
45
@@ -62,6 +63,7 @@ To animate the :py:class:`MArray`, simply invoke the ``animate`` property as sho
62
63
Moreover, you can also use the :py:func:`MArray.animate_elem` method to animate a single element of the :py:class:`MArray` as well:
63
64
64
65
.. code-block:: python
66
+
:linenos:
65
67
66
68
self.play(arr.animate_elem(1).shift(DOWN))
67
69
@@ -85,6 +87,7 @@ Moreover, you can also use the :py:func:`MArray.animate_elem` method to animate
85
87
Lastly, you can also animate the body, value and the index of any element using the :py:func:`MArray.animate_elem_square`, :py:func:`MArray.animate_elem_value` and :py:func:`MArray.animate_elem_index` respectively.
86
88
87
89
.. code-block:: python
90
+
:linenos:
88
91
89
92
self.play(
90
93
arr.animate_elem_square(1).set_fill(BLACK),
@@ -119,6 +122,7 @@ Customizing MArray
119
122
The :py:class:`MArray` also allows you to alter the way your array looks. While creating your array pass arguments to ``Square`` (used to represent the element body) and ``Text`` (used to represent the element value and index) mobjects.
120
123
121
124
.. code-block:: python
125
+
:linenos:
122
126
123
127
arr = MArray(
124
128
[1, 2, 3],
@@ -206,7 +210,71 @@ To do this, simply pass your preferred direction enum from :py:class:`MArrayDire
206
210
207
211
self.wait(1)
208
212
209
-
.. currentmodule:: manim_data_structures.array
213
+
Array Label
214
+
^^^^^^^^^^^
215
+
216
+
.. currentmodule:: manim_data_structures.m_array
217
+
218
+
For an :py:class:`MArray`, you can also a label with the array via specifying the ``label`` argument.
219
+
220
+
.. currentmodule:: manim_data_structures.m_enum
221
+
222
+
Similar to how we specify the growth direction using :py:class:`MArrayDirection` enum, we can dictate the position of the label.
You can also pass ``mob_*_args`` to this method to customize the inserted element.
327
395
396
+
Did you notice the the ``*`` before we invoked the :py:func:`MArray.append_elem` method? Since the method returns a list of :py:class:`manim.Animation` therefore, we unpack it while feeding it to the ``self.play`` method of the ``Scene``.
397
+
398
+
Moreover, you can also specify the animation that is played for the inserted element via the ``append_anim`` argument. The code snippet below passes the :py:class:`manim.GrowFromCenter` animation to the :py:class:`MArray.append_elem` method:
You can also specify arguments to the passed animation via the ``append_anim_args`` parameter and also set the target of the animation using the ``append_anim_target`` parameter that takes in :py:class:`MArrayElementComp` enum.
428
+
429
+
Remove Element
430
+
^^^^^^^^^^^^^^
431
+
432
+
.. currentmodule:: manim_data_structures.m_array
433
+
434
+
To remove an element simply invoke the :py:class:`MArray.remove_elem` method with the index of element you wish to remove. The method returns two the removal animation and a function that udpates the indices of the remaining elements.
Similar to how you were able to pass the append animation to the :py:class:`MArray.append_elem` function, you can specify two animations for the :py:class:`MArray.remove_elem` method:
464
+
1. Element removal animation via the ``removal_anim`` parameter.
465
+
2. Indices update animation via the ``update_anim`` parameter.
You can also specify arguments to the passed animation via the ``*_anim_args`` parameter and also set the target of the animation using the ``*_anim_target`` parameter.
0 commit comments