Skip to content

Commit

Permalink
rebase onto upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
eulertour committed May 28, 2019
2 parents e59178d + 78448b4 commit 0edb4ed
Show file tree
Hide file tree
Showing 36 changed files with 1,348 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
python: "3.7"
cache: pip

addons:
apt:
packages:
- python3-sphinx
install:
- pip install --upgrade pip
- pip install -r requirements.txt
Expand All @@ -16,6 +20,8 @@ before_script:
script:
- python setup.py test
- python setup.py bdist_wheel
after_success:
- test $TRAVIS_BRANCH = "master" && test $TRAVIS_PULL_REQUEST = "false" && travis/build_docs.sh
deploy:
provider: pypi
user: eulertour
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Manim - Mathematical Animation Engine
<img src="logo/cropped.png"/>

[![Documentation Status](https://readthedocs.org/projects/manim/badge/?version=latest)](https://manim.readthedocs.io/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/3b1b/manim.svg?branch=master)](https://travis-ci.org/3b1b/manim)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://choosealicense.com/licenses/mit/)
Expand Down Expand Up @@ -87,15 +88,17 @@ Try running the following:
```sh
python3 -m manim example_scenes.py SquareToCircle -pl
```
The -p is for previewing, meaning the video file will automatically open when it is done rendering.
Use -l for a faster rendering at a lower quality.
Use -s to skip to the end and just show the final frame.
Use -n (number) to skip ahead to the n'th animation of a scene.
Use -f to show the file in finder (for osx)
The `-p` flag in the command above is for previewing, meaning the video file will automatically open when it is done rendering. The `-l` flag is for a faster rendering at a lower quality.

Some other useful flags include:

* `-s` to skip to the end and just show the final frame.
* `-n <number>` to skip ahead to the `n`'th animation of a scene.
* `-f` to show the file in finder (for OSX).

Set MEDIA_DIR environment variable to determine where image and animation files will be written.
Set `MEDIA_DIR` environment variable to specify where the image and animation files will be written.

Look through the old_projects folder to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility on those old_projects. To run them with a guarantee that they will work, you will have to go back to the commit which complete that project.
Look through the `old_projects` folder to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility with those old projects. To run an old project with a guarantee that it will work, you will have to go back to the commit which completed that project.

While developing a scene, the `-sp` flags are helpful to just see what things look like at the end without having to generate the full animation. It can also be helpful to use the `-n` flag to skip over some number of animations.

Expand Down
13 changes: 13 additions & 0 deletions active_projects/ode/all_part3_scenes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from active_projects.ode.part3.staging import *
from active_projects.ode.part3.temperature_graphs import *


OUTPUT_DIRECTORY = "ode/part3"
SCENES_IN_ORDER = [
FourierSeriesIllustraiton,
FourierNameIntro,
CircleAnimationOfF,
LastChapterWrapper,
ThreeMainObservations,
SimpleSinExpGraph,
]
40 changes: 40 additions & 0 deletions active_projects/ode/name_animations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python
from manimlib.imports import *
from active_projects.ode.part2.fourier_series import FourierOfName

name_color_pairs = [

]

circle_counts = [
# 10,
# 25,
100,
]

if __name__ == "__main__":
for name, color in name_color_pairs:
for n_circles in circle_counts:
try:
first_name = name.split(" ")[0]
scene = FourierOfName(
name_text=name,
name_color=color,
n_circles=n_circles,
file_writer_config={
"write_to_movie": True,
"output_directory": os.path.join(
"patron_fourier_names",
first_name,
),
"file_name": "{}_Fouierified_{}_Separate_paths".format(
first_name,
n_circles
),
},
camera_config={
"frame_rate": 24,
},
)
except:
pass
62 changes: 55 additions & 7 deletions active_projects/ode/part2/fourier_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,7 @@ def construct(self):
coefs = self.get_coefficients_of_path(path)

circles = self.get_circles(coefficients=coefs)
for k, circle in zip(it.count(1), circles):
circle.set_stroke(width=max(
1 / np.sqrt(k),
1,
))

self.set_decreasing_stroke_widths(circles)
# approx_path = self.get_circle_end_path(circles)
drawn_path = self.get_drawn_path(circles)
if self.start_drawn:
Expand All @@ -329,6 +324,14 @@ def construct(self):
self.add(drawn_path)
self.wait(self.run_time)

def set_decreasing_stroke_widths(self, circles):
for k, circle in zip(it.count(1), circles):
circle.set_stroke(width=max(
1 / np.sqrt(k),
1,
))
return circles

def get_path(self):
tex_mob = TexMobject(self.tex)
tex_mob.set_height(6)
Expand All @@ -338,6 +341,51 @@ def get_path(self):
return path


class FourierOfName(FourierOfPiSymbol):
CONFIG = {
"n_circles": 100,
"name_color": WHITE,
"name_text": "Abc",
"time_per_symbol": 5,
"slow_factor": 1 / 5,
}

def construct(self):
name = TextMobject(self.name_text)
max_width = FRAME_WIDTH - 2
max_height = FRAME_HEIGHT - 2
name.set_width(max_width)
if name.get_height() > max_height:
name.set_height(max_height)

circles = VGroup(VectorizedPoint())
for path in name.family_members_with_points():
for subpath in path.get_subpaths():
sp_mob = VMobject()
sp_mob.set_points(subpath)
coefs = self.get_coefficients_of_path(sp_mob)
new_circles = self.get_circles(
coefficients=coefs
)
self.set_decreasing_stroke_widths(new_circles)
drawn_path = self.get_drawn_path(new_circles)
drawn_path.clear_updaters()
drawn_path.set_stroke(self.name_color, 3)

new_circles.suspend_updating()
self.play(ReplacementTransform(circles, new_circles))
new_circles.resume_updating()
circles = new_circles
self.play(
ShowCreation(drawn_path),
rate_func=linear,
run_time=self.time_per_symbol
)
circles.suspend_updating()
self.play(FadeOut(circles))
self.wait(3)


class FourierOfPiSymbol5(FourierOfPiSymbol):
CONFIG = {
"n_circles": 5,
Expand Down Expand Up @@ -479,7 +527,7 @@ class FourierNDQ(FourierOfTrebleClef):

def get_shape(self):
path = VMobject()
shape = TexMobject("Hayley")
shape = TexMobject("NDQ")
for sp in shape.family_members_with_points():
path.append_points(sp.points)
return path
Expand Down

0 comments on commit 0edb4ed

Please sign in to comment.