mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Update learning_by_example.rst
Updated getting started to accomodate manimlib (pip installation)
This commit is contained in:
parent
57b96fdd07
commit
62206bc0e7
1 changed files with 53 additions and 37 deletions
|
@ -2,12 +2,14 @@ Learning by Example
|
||||||
===================
|
===================
|
||||||
|
|
||||||
You create videos in manim by writing :class:`~scene.scene.Scene` instances.
|
You create videos in manim by writing :class:`~scene.scene.Scene` instances.
|
||||||
``example_scenes.py`` contains a few simple ones that we can use to learn about
|
`example_scenes.py <https://github.com/3b1b/manim/blob/master/example_scenes.py>`_. contains a few simple ones that we can use to learn about
|
||||||
manim. For instance, take ``SquareToCircle``.
|
manim. For instance, take ``SquareToCircle``. Copy the code given below to a new file (say test_manim.py) and run it with ``$ manim test_manim.py SquareToCircle -p``.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
|
from manimlib.imports import *
|
||||||
|
|
||||||
class SquareToCircle(Scene):
|
class SquareToCircle(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
circle = Circle()
|
circle = Circle()
|
||||||
|
@ -20,49 +22,63 @@ manim. For instance, take ``SquareToCircle``.
|
||||||
self.play(Transform(square, circle))
|
self.play(Transform(square, circle))
|
||||||
self.play(FadeOut(square))
|
self.play(FadeOut(square))
|
||||||
|
|
||||||
|
|
||||||
:meth:`~scene.scene.Scene.construct` specifies what is displayed on the screen
|
:meth:`~scene.scene.Scene.construct` specifies what is displayed on the screen
|
||||||
when the :class:`~scene.scene.Scene` is rendered to video. You can render a
|
when the :class:`~scene.scene.Scene` is rendered to video. The flag ``-p`` automatically plays the rendered video.
|
||||||
:class:`~scene.scene.Scene` by running ``extract_scene.py``. Run ``python
|
Other frequently used flags are ``-l`` for rendering video in lower resolution (in favour of higher speed) and ``-s`` to show the last frame of the video.
|
||||||
extract_scene.py -h`` to see how it's used.
|
Run ``manim -h`` all the available flags
|
||||||
|
|
||||||
.. code-block:: none
|
.. code-block:: none
|
||||||
|
|
||||||
> python extract_scene.py -h
|
> manim -h
|
||||||
usage: extract_scene.py [-h] [-p] [-w] [-s] [-l] [-m] [-g] [-f] [-t] [-q] [-a]
|
Media will be stored in ./media/. You can change this behavior by writing a different directory to media_dir.txt.
|
||||||
[-o OUTPUT_NAME] [-n START_AT_ANIMATION_NUMBER]
|
usage: manim [-h] [-p] [-w] [-s] [-l] [-m] [-g] [-f] [-t] [-q] [-a]
|
||||||
[-r RESOLUTION] [-c COLOR] [-d OUTPUT_DIRECTORY]
|
[-o FILE_NAME] [-n START_AT_ANIMATION_NUMBER] [-r RESOLUTION]
|
||||||
file [scene_name]
|
[-c COLOR] [--sound] [--leave_progress_bars] [--livestream]
|
||||||
|
[--to-twitch] [--with-key TWITCH_KEY]
|
||||||
|
[file] [scene_names [scene_names ...]]
|
||||||
|
|
||||||
positional arguments:
|
positional arguments:
|
||||||
file path to file holding the python code for the scene
|
file path to file holding the python code for the scene
|
||||||
scene_name Name of the Scene class you want to see
|
scene_names Name of the Scene class you want to see
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-p, --preview
|
-p, --preview Automatically open the saved file once its done
|
||||||
-w, --write_to_movie
|
-w, --write_to_movie Render the scene as a movie file
|
||||||
-s, --show_last_frame
|
-s, --save_last_frame
|
||||||
-l, --low_quality
|
Save the last frame
|
||||||
-m, --medium_quality
|
-l, --low_quality Render at a low quality (for faster rendering)
|
||||||
-g, --save_pngs
|
-m, --medium_quality Render at a medium quality
|
||||||
|
-g, --save_pngs Save each frame as a png
|
||||||
-f, --show_file_in_finder
|
-f, --show_file_in_finder
|
||||||
-t, --transparent
|
Show the output file in finder
|
||||||
|
-t, --transparent Render to a movie file with an alpha channel
|
||||||
-q, --quiet
|
-q, --quiet
|
||||||
-a, --write_all
|
-a, --write_all Write all the scenes from a file
|
||||||
-o OUTPUT_NAME, --output_name OUTPUT_NAME
|
-o FILE_NAME, --file_name FILE_NAME
|
||||||
|
Specify the name of the output file, ifit should be
|
||||||
|
different from the scene class name
|
||||||
-n START_AT_ANIMATION_NUMBER, --start_at_animation_number START_AT_ANIMATION_NUMBER
|
-n START_AT_ANIMATION_NUMBER, --start_at_animation_number START_AT_ANIMATION_NUMBER
|
||||||
|
Start rendering not from the first animation, butfrom
|
||||||
|
another, specified by its index. If you passin two
|
||||||
|
comma separated values, e.g. "3,6", it will endthe
|
||||||
|
rendering at the second value
|
||||||
-r RESOLUTION, --resolution RESOLUTION
|
-r RESOLUTION, --resolution RESOLUTION
|
||||||
|
Resolution, passed as "height,width"
|
||||||
-c COLOR, --color COLOR
|
-c COLOR, --color COLOR
|
||||||
-d OUTPUT_DIRECTORY, --output_directory OUTPUT_DIRECTORY
|
Background color
|
||||||
|
--sound Play a success/failure sound
|
||||||
|
--leave_progress_bars
|
||||||
|
Leave progress bars displayed in terminal
|
||||||
|
--livestream Run in streaming mode
|
||||||
|
--to-twitch Stream to twitch
|
||||||
|
--with-key TWITCH_KEY
|
||||||
|
Stream key for twitch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The most common flags are ``-p``, to automatically play the generated video,
|
|
||||||
``-l``, to render in lower quality in favor of speed, and ``-s``, to show the
|
|
||||||
last frame of the :class:`~scene.scene.Scene` for faster development. Run
|
|
||||||
``python extract_scene.py example_scenes.py SquareToCircle -pl`` to produce a
|
|
||||||
file called SquareToCircle.mp4 in the media directory that you have configured,
|
|
||||||
and automatically play it.
|
|
||||||
|
|
||||||
.. raw:: html
|
|
||||||
|
|
||||||
<video width="560" height="315" controls>
|
<video width="560" height="315" controls>
|
||||||
<source src="../_static/SquareToCircle.mp4" type="video/mp4">
|
<source src="../_static/SquareToCircle.mp4" type="video/mp4">
|
||||||
|
|
Loading…
Add table
Reference in a new issue