@@ -52,8 +52,6 @@ def construct(self):
52
52
file_writer : The object that writes the animations in the scene to a video file.
53
53
mobjects : The list of mobjects present in the scene.
54
54
foreground_mobjects : List of mobjects explicitly in the foreground.
55
- num_plays : Number of play() functions in the scene.
56
- time: time elapsed since initialisation of scene.
57
55
random_seed: The seed with which all random operations are done.
58
56
59
57
"""
@@ -73,15 +71,10 @@ def __init__(self, **kwargs):
73
71
** file_writer_config ,
74
72
)
75
73
self .renderer = CairoRenderer (self , self .camera , self .file_writer )
76
- self .play_hashes_list = []
77
74
78
75
self .mobjects = []
79
- self .original_skipping_status = file_writer_config ["skip_animations" ]
80
76
# TODO, remove need for foreground mobjects
81
77
self .foreground_mobjects = []
82
- self .num_plays = 0
83
- self .time = 0
84
- self .original_skipping_status = file_writer_config ["skip_animations" ]
85
78
if self .random_seed is not None :
86
79
random .seed (self .random_seed )
87
80
np .random .seed (self .random_seed )
@@ -96,13 +89,8 @@ def render(self):
96
89
self .construct ()
97
90
except EndSceneEarlyException :
98
91
pass
99
-
100
92
self .tear_down ()
101
- # We have to reset these settings in case of multiple renders.
102
- file_writer_config ["skip_animations" ] = False
103
-
104
- self .file_writer .finish ()
105
- self .print_end_message ()
93
+ self .renderer .finish ()
106
94
107
95
def setup (self ):
108
96
"""
@@ -130,15 +118,6 @@ def construct(self):
130
118
def __str__ (self ):
131
119
return self .__class__ .__name__
132
120
133
- def print_end_message (self ):
134
- """
135
- Used internally to print the number of
136
- animations played after the scene ends,
137
- as well as the name of the scene rendered
138
- (useful when using the `-a` option).
139
- """
140
- logger .info (f"Rendered { str (self )} \n Played { self .num_plays } animations" )
141
-
142
121
def set_variables_as_attrs (self , * objects , ** newly_named_objects ):
143
122
"""
144
123
This method is slightly hacky, making it a little easier
@@ -199,18 +178,6 @@ def should_update_mobjects(self):
199
178
200
179
###
201
180
202
- def increment_time (self , d_time ):
203
- """
204
- Increments the time elapsed after intialisation of scene by
205
- passed "d_time".
206
-
207
- Parameters
208
- ----------
209
- d_time : int or float
210
- Time in seconds to increment by.
211
- """
212
- self .time += d_time
213
-
214
181
###
215
182
216
183
def get_top_level_mobjects (self ):
@@ -646,7 +613,7 @@ def get_animation_time_progression(self, animations):
646
613
time_progression .set_description (
647
614
"" .join (
648
615
[
649
- "Animation {}: " .format (self .num_plays ),
616
+ "Animation {}: " .format (self .renderer . num_plays ),
650
617
str (animations [0 ]),
651
618
(", etc." if len (animations ) > 1 else "" ),
652
619
]
@@ -799,66 +766,10 @@ def finish_animations(self, animations):
799
766
self .update_mobjects (0 )
800
767
801
768
def wait (self , duration = DEFAULT_WAIT_TIME , stop_condition = None ):
802
- self .play (duration = duration , stop_condition = stop_condition )
769
+ self .renderer . wait (duration = duration , stop_condition = stop_condition )
803
770
804
771
def play (self , * args , ** kwargs ):
805
- self .cached_play (* args , ** kwargs )
806
- self .num_plays += 1
807
-
808
- def revert_to_original_skipping_status (self ):
809
- """
810
- Forces the scene to go back to its original skipping status,
811
- by setting skip_animations to whatever it reads
812
- from original_skipping_status.
813
-
814
- Returns
815
- -------
816
- Scene
817
- The Scene, with the original skipping status.
818
- """
819
- if hasattr (self , "original_skipping_status" ):
820
- file_writer_config ["skip_animations" ] = self .original_skipping_status
821
- return self
822
-
823
- def cached_play (self , * args , ** kwargs ):
824
- self .revert_to_original_skipping_status ()
825
- self .renderer .update_skipping_status ()
826
- animations = self .compile_play_args_to_animation_list (* args , ** kwargs )
827
- self .add_mobjects_from_animations (animations )
828
- if file_writer_config ["skip_animations" ]:
829
- logger .debug (f"Skipping animation { self .num_plays } " )
830
- self .file_writer_wrapped_play (* args , ** kwargs )
831
- return
832
- if not file_writer_config ["disable_caching" ]:
833
- mobjects_on_scene = self .get_mobjects ()
834
- hash_play = get_hash_from_play_call (
835
- self , self .camera , animations , mobjects_on_scene
836
- )
837
- self .play_hashes_list .append (hash_play )
838
- if self .file_writer .is_already_cached (hash_play ):
839
- logger .info (
840
- f"Animation { self .num_plays } : Using cached data (hash : %(hash_play)s)" ,
841
- {"hash_play" : hash_play },
842
- )
843
- file_writer_config ["skip_animations" ] = True
844
- else :
845
- hash_play = "uncached_{:05}" .format (self .num_plays )
846
- self .play_hashes_list .append (hash_play )
847
- self .file_writer_wrapped_play (* args , ** kwargs )
848
-
849
- def file_writer_wrapped_play (self , * args , ** kwargs ):
850
- allow_write = not file_writer_config ["skip_animations" ]
851
- self .file_writer .begin_animation (allow_write )
852
-
853
- self .play_or_wait (* args , ** kwargs )
854
-
855
- self .file_writer .end_animation (allow_write )
856
-
857
- def play_or_wait (self , * args , ** kwargs ):
858
- if "duration" in kwargs :
859
- self .wait_internal (** kwargs )
860
- else :
861
- self .play_internal (* args , ** kwargs )
772
+ self .renderer .play (* args , ** kwargs )
862
773
863
774
def play_internal (self , * args , ** kwargs ):
864
775
"""
@@ -969,7 +880,9 @@ def get_wait_time_progression(self, duration, stop_condition):
969
880
)
970
881
else :
971
882
time_progression = self .get_time_progression (duration )
972
- time_progression .set_description ("Waiting {}" .format (self .num_plays ))
883
+ time_progression .set_description (
884
+ "Waiting {}" .format (self .renderer .num_plays )
885
+ )
973
886
return time_progression
974
887
975
888
def wait_until (self , stop_condition , max_time = 60 ):
0 commit comments