Skip to content

Commit be6a9df

Browse files
authored
docs: add explanation about the rate_func in the custom animation (#4278)
1 parent e569fd4 commit be6a9df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/source/tutorials/building_blocks.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ Generally, you start with the starting number and add only some part of the valu
327327
So, the logic of calculating the number to display at each step will be ``50 + alpha * (100 - 50)``.
328328
Once you set the calculated value for the :class:`~.DecimalNumber`, you are done.
329329

330+
.. note::
331+
332+
If you're creating a custom animation and want to use a ``rate_func``, you must explicitly apply
333+
``self.rate_func(alpha)`` to the parameter you're animating. For example, try switching the rate
334+
function to ``rate_functions.there_and_back`` to observe how it affects the counting behavior.
335+
336+
330337
Once you have defined your ``Count`` animation, you can play it in your :class:`~.Scene` for any duration you want for any :class:`~.DecimalNumber` with any rate function.
331338

332339
.. manim:: CountingScene
@@ -343,7 +350,7 @@ Once you have defined your ``Count`` animation, you can play it in your :class:`
343350
344351
def interpolate_mobject(self, alpha: float) -> None:
345352
# Set value of DecimalNumber according to alpha
346-
value = self.start + (alpha * (self.end - self.start))
353+
value = self.start + (self.rate_func(alpha) * (self.end - self.start))
347354
self.mobject.set_value(value)
348355

349356

0 commit comments

Comments
 (0)