@@ -18,7 +18,7 @@ At this point, you have just executed the following command.
1818
1919 Let's dissect what just happened step by step. First, this command executes
2020manim on the file ``scene.py ``, which contains our animation code. Further,
21- this command tells manim exactly which `` Scene ` ` is to be rendered, in this case,
21+ this command tells manim exactly which :class: ` . Scene ` is to be rendered, in this case,
2222it is ``SquareToCircle ``. This is necessary because a single scene file may
2323contain more than one scene. Next, the flag `-p ` tells manim to play the scene
2424once it's rendered, and the `-ql ` flag tells manim to render the scene in low
@@ -140,44 +140,73 @@ resolutions, e.g. ``-s -ql``, ``-s -qh``
140140Sections
141141********
142142
143- In addition to the movie output file one can use sections. Each section produces
144- its own output video. The cuts between two sections can be set like this:
143+ In addition to the movie output file one can use sections. If :attr: ` ManimConfig.save_sections ` is `` True ``,
144+ each section produces its own output video. In order to use sections, set :attr: ` ~Scene.sections_api ` to `` True ``.
145145
146146.. code-block :: python
147147
148- def construct (self ):
149- # play the first animations...
150- # you don't need a section in the very beginning as it gets created automatically
151- self .next_section()
152- # play more animations...
153- self .next_section(" this is an optional name that doesn't have to be unique" )
154- # play even more animations...
155- self .next_section(" this is a section without any animations, it will be removed" )
148+ class MyScene (Scene ):
149+ sections_api = True
150+
151+ @section
152+ def introduction (self ):
153+ # play the first animations...
154+ # the default name of this section is the name of the method
155+ ...
156+
157+ @section (name = " this is an optional name that doesn't have to be unique" )
158+ def second_section (self ):
159+ # play more animations...
160+ ...
161+
162+ @section (skip = True )
163+ def finale (self ):
164+ # play even more animations...
165+ # however, they won't be included in the final output video
166+ ...
156167
157168 All the animations between two of these cuts get concatenated into a single output
158169video file.
159170Be aware that you need at least one animation in each section. For example this wouldn't create an output video:
160171
161172.. code-block :: python
162173
163- def construct (self ):
164- self .next_section()
165- # this section doesn't have any animations and will be removed
166- # but no error will be thrown
167- # feel free to tend your flock of empty sections if you so desire
168- self .add(Circle())
169- self .next_section()
174+ class SectionsExampleWithNoAnimations (Scene ):
175+ sections_api = True
176+
177+ @section
178+ def first (self ):
179+ self .next_section()
180+ # this section doesn't have any animations and will be removed
181+ # but no error will be thrown
182+ # feel free to tend your flock of empty sections if you so desire
183+ self .add(Circle())
184+
185+ @section
186+ def next (self ):
187+ # play some animations
188+ ...
170189
171190 One way of fixing this is to wait a little:
172191
173192.. code-block :: python
174193
175- def construct (self ):
176- self .next_section()
177- self .add(Circle())
178- # now we wait 1sec and have an animation to satisfy the section
179- self .wait()
180- self .next_section()
194+ class SectionsExampleWithNoAnimations (Scene ):
195+ sections_api = True
196+
197+ @section
198+ def first (self ):
199+ self .next_section()
200+ # this section doesn't have any animations and will be removed
201+ # but no error will be thrown
202+ # feel free to tend your flock of empty sections if you so desire
203+ self .add(Circle())
204+ self .wait()
205+
206+ @section
207+ def next (self ):
208+ # play some animations
209+ ...
181210
182211 For videos to be created for each section you have to add the ``--save_sections `` flag to the Manim call like this:
183212
@@ -258,13 +287,20 @@ You can also skip rendering all animations belonging to a section like this:
258287
259288.. code-block :: python
260289
261- def construct (self ):
262- self .next_section(skip_animations = True )
263- # play some animations that shall be skipped...
264- self .next_section()
265- # play some animations that won't get skipped...
290+ class SkippingSections (Scene ):
291+ sections_api = True
266292
293+ @section (skip = True )
294+ def first (self ):
295+ # play some animations
296+ # things here will execute, but they
297+ # won't be written to the output file
298+ ...
267299
300+ @section
301+ def next (self ):
302+ # play some animations
303+ ...
268304
269305
270306 Some command line flags
@@ -277,9 +313,9 @@ When executing the command
277313 manim -pql scene.py SquareToCircle
278314
279315 it specifies the scene to render. This is not necessary now. When a single
280- file contains only one `` Scene `` class, it will just render the `` Scene ` `
281- class. When a single file contains more than one `` Scene ` ` class, manim will
282- let you choose a `` Scene `` class. If your file contains multiple `` Scene ` `
316+ file contains only one :class: ` . Scene ` class, it will just render the :class: ` . Scene `
317+ class. When a single file contains more than one :class: ` . Scene ` class, manim will
318+ let you choose a :class: ` . Scene ` class. If your file contains multiple :class: ` . Scene `
283319classes, and you want to render them all, you can use the ``-a `` flag.
284320
285321As discussed previously, the ``-ql `` specifies low render quality (854x480
@@ -294,7 +330,7 @@ the file browser at the location of the animation instead of playing it, you
294330can use the ``-f `` flag. You can also omit these two flags.
295331
296332Finally, by default manim will output .mp4 files. If you want your animations
297- in .gif format instead, use the ``--format gif `` flag. The output files will
333+ in .gif format instead, use the ``--format= gif `` flag. The output files will
298334be in the same folder as the .mp4 files, and with the same name, but a
299335different file extension.
300336
0 commit comments