@@ -37,10 +37,9 @@ def handle_play_like_call(func):
3737 """
3838
3939 def wrapper (self , scene , * args , ** kwargs ):
40- allow_write = not config ["skip_animations" ]
41- self .file_writer .begin_animation (allow_write )
40+ self .file_writer .begin_animation (not self .skip_animations )
4241 func (self , scene , * args , ** kwargs )
43- self .file_writer .end_animation (allow_write )
42+ self .file_writer .end_animation (not self . skip_animations )
4443 self .num_plays += 1
4544
4645 return wrapper
@@ -53,7 +52,7 @@ class CairoRenderer:
5352 time: time elapsed since initialisation of scene.
5453 """
5554
56- def __init__ (self , camera_class = None , ** kwargs ):
55+ def __init__ (self , camera_class = None , skip_animations = False , ** kwargs ):
5756 # All of the following are set to EITHER the value passed via kwargs,
5857 # OR the value stored in the global config dict at the time of
5958 # _instance construction_. Before, they were in the CONFIG dict, which
@@ -72,7 +71,8 @@ def __init__(self, camera_class=None, **kwargs):
7271 self .video_quality_config [attr ] = kwargs .get (attr , config [attr ])
7372 camera_cls = camera_class if camera_class is not None else Camera
7473 self .camera = camera_cls (self .video_quality_config )
75- self .original_skipping_status = config ["skip_animations" ]
74+ self .original_skipping_status = skip_animations
75+ self .skip_animations = skip_animations
7676 self .animations_hashes = []
7777 self .num_plays = 0
7878 self .time = 0
@@ -116,7 +116,7 @@ def update_frame( # TODO Description in Docstring
116116 **kwargs
117117
118118 """
119- if config [ " skip_animations" ] and not ignore_skipping :
119+ if self . skip_animations and not ignore_skipping :
120120 return
121121 if mobjects is None :
122122 mobjects = list_update (
@@ -156,7 +156,7 @@ def add_frame(self, frame, num_frames=1):
156156 """
157157 dt = 1 / self .camera .frame_rate
158158 self .time += num_frames * dt
159- if config [ " skip_animations" ] :
159+ if self . skip_animations :
160160 return
161161 for _ in range (num_frames ):
162162 self .file_writer .write_frame (frame )
@@ -179,29 +179,14 @@ def update_skipping_status(self):
179179 """
180180 if config ["from_animation_number" ]:
181181 if self .num_plays < config ["from_animation_number" ]:
182- config [ " skip_animations" ] = True
182+ self . skip_animations = True
183183 if config ["upto_animation_number" ]:
184184 if self .num_plays > config ["upto_animation_number" ]:
185- config [ " skip_animations" ] = True
185+ self . skip_animations = True
186186 raise EndSceneEarlyException ()
187187
188- def revert_to_original_skipping_status (self ):
189- """
190- Forces the scene to go back to its original skipping status,
191- by setting skip_animations to whatever it reads
192- from original_skipping_status.
193-
194- Returns
195- -------
196- Scene
197- The Scene, with the original skipping status.
198- """
199- if hasattr (self , "original_skipping_status" ):
200- config ["skip_animations" ] = self .original_skipping_status
201- return self
202-
203188 def finish (self , scene ):
204- config [ " skip_animations" ] = False
189+ self . skip_animations = self . original_skipping_status
205190 self .file_writer .finish ()
206191 if config ["save_last_frame" ]:
207192 self .update_frame (scene , ignore_skipping = False )
0 commit comments