16
16
17
17
18
18
class ChangingDecimal (Animation ):
19
+ """Animate a :class:`~.DecimalNumber` to values specified by a user-supplied function.
20
+
21
+ Parameters
22
+ ----------
23
+ decimal_mob
24
+ The :class:`~.DecimalNumber` instance to animate.
25
+ number_update_func
26
+ A function that returns the number to display at each point in the animation.
27
+ suspend_mobject_updating
28
+ If ``True``, the mobject is not updated outside this animation.
29
+
30
+ Raises
31
+ ------
32
+ TypeError
33
+ If ``decimal_mob`` is not an instance of :class:`~.DecimalNumber`.
34
+
35
+ Examples
36
+ --------
37
+
38
+ .. manim:: ChangingDecimalExample
39
+
40
+ class ChangingDecimalExample(Scene):
41
+ def construct(self):
42
+ number = DecimalNumber(0)
43
+ self.add(number)
44
+ self.play(
45
+ ChangingDecimal(
46
+ number,
47
+ lambda a: 5 * a,
48
+ run_time=3
49
+ )
50
+ )
51
+ self.wait()
52
+ """
53
+
19
54
def __init__ (
20
55
self ,
21
56
decimal_mob : DecimalNumber ,
@@ -38,6 +73,28 @@ def interpolate_mobject(self, alpha: float) -> None:
38
73
39
74
40
75
class ChangeDecimalToValue (ChangingDecimal ):
76
+ """Animate a :class:`~.DecimalNumber` to a target value using linear interpolation.
77
+
78
+ Parameters
79
+ ----------
80
+ decimal_mob
81
+ The :class:`~.DecimalNumber` instance to animate.
82
+ target_number
83
+ The target value to transition to.
84
+
85
+ Examples
86
+ --------
87
+
88
+ .. manim:: ChangeDecimalToValueExample
89
+
90
+ class ChangeDecimalToValueExample(Scene):
91
+ def construct(self):
92
+ number = DecimalNumber(0)
93
+ self.add(number)
94
+ self.play(ChangeDecimalToValue(number, 10, run_time=3))
95
+ self.wait()
96
+ """
97
+
41
98
def __init__ (
42
99
self , decimal_mob : DecimalNumber , target_number : int , ** kwargs : Any
43
100
) -> None :
0 commit comments