/ tests / test_animate_api.py
test_animate_api.py
 1  """
 2  test_animate_api.py - Test the fluent .animate API
 3  
 4  Tests:
 5  1. Basic parameter animation: circle.animate.x(100)
 6  2. Sequence animation: breath.animate.expansion.sequence(0, 1, 0)
 7  3. Chained animations: circle.animate.x(100).y(50)
 8  4. UserData parameter animation via name lookup
 9  
10  The fluent API should make animations more readable:
11      # Old style
12      self.play(Move(circle, x=100), run_time=1)
13  
14      # New fluent style
15      self.play(circle.animate.x(100), run_time=1)
16  """
17  
18  from DreamTalk.imports import *
19  
20  
21  class AnimateAPITest(Dream):
22      """Test the fluent animation API."""
23  
24      def unfold(self):
25          # Create a simple circle
26          circle = Circle(radius=100, color=WHITE)
27  
28          # Test 1: Basic position animation using .animate
29          self.play(circle.animate.x(150), run_time=1)
30  
31          # Test 2: Chain x and y
32          self.play(circle.animate.x(-150).y(100), run_time=1)
33  
34          # Test 3: Back to center
35          self.play(circle.animate.x(0).y(0), run_time=0.5)
36  
37          self.wait(0.5)
38  
39  
40  if __name__ == "__main__":
41      AnimateAPITest()