Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Added documentation and example for :class:`.CyclicReplace` (#2978)

Jérome Eertmans44ce03165891
diff --git a/manim/animation/transform.py b/manim/animation/transform.py
index cdf44f409..d4584c896 100644
--- a/manim/animation/transform.py
+++ b/manim/animation/transform.py
@@ -691,6 +691,37 @@ class ApplyComplexFunction(ApplyMethod):
class CyclicReplace(Transform):
+ """An animation moving mobjects cyclically.
+
+ In particular, this means: the first mobject takes the place
+ of the second mobject, the second one takes the place of
+ the third mobject, and so on. The last mobject takes the
+ place of the first one.
+
+ Parameters
+ ----------
+ mobjects
+ List of mobjects to be transformed.
+ path_arc
+ The angle of the arc (in radians) that the mobjects will follow to reach
+ their target.
+ kwargs
+ Further keyword arguments that are passed to :class:`.Transform`.
+
+ Examples
+ --------
+ .. manim :: CyclicReplaceExample
+
+ class CyclicReplaceExample(Scene):
+ def construct(self):
+ group = VGroup(Square(), Circle(), Triangle(), Star())
+ group.arrange(RIGHT)
+ self.add(group)
+
+ for _ in range(4):
+ self.play(CyclicReplace(*group))
+ """
+
def __init__(
self, *mobjects: Mobject, path_arc: float = 90 * DEGREES, **kwargs
) -> None: