Skip to content

Commit 2687e74

Browse files
author
Hugues Devimeux
committed
Merge branch 'master' of https://github.com/ManimCommunity/manim into fix-set-test-scene
2 parents ef9eb02 + d09f593 commit 2687e74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2967
-1178
lines changed

.github/manimdependency.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
{
2-
"windows": {
3-
"ffmpeg": "https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.1-2020-09-21-full_build.zip",
4-
"pango": "v0.1.0"
5-
}
2+
"windows": {
3+
"ffmpeg": "https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.1-2020-09-21-full_build.zip",
4+
"pango": "v0.1.0",
5+
"tinytex": [
6+
"standalone",
7+
"preview",
8+
"doublestroke",
9+
"ms",
10+
"setspace",
11+
"rsfs",
12+
"relsize",
13+
"ragged2e",
14+
"fundus-calligra",
15+
"microtype",
16+
"wasysym",
17+
"physics",
18+
"dvisvgm",
19+
"jknapltx",
20+
"wasy",
21+
"cm-super",
22+
"babel-english"
23+
]
24+
}
625
}

.github/workflows/ci.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
name: CI
22
on:
33
push:
4-
branches:
5-
- master
4+
branches:
5+
- master
66
pull_request:
7-
branches:
8-
- master
7+
branches:
8+
- master
99

1010
jobs:
1111
test:
1212
runs-on: ${{ matrix.os }}
1313
env:
14-
POETRY_VIRTUALENVS_CREATE: false
14+
POETRY_VIRTUALENVS_CREATE: false
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest, macos-latest, windows-latest]
19-
python: [3.6,3.7, 3.8]
19+
python: [3.6, 3.7, 3.8]
2020

2121
steps:
2222
- name: Checkout the repository
@@ -36,8 +36,8 @@ jobs:
3636
shell: bash
3737
id: pip-cache-and-time
3838
run: |
39-
echo "::set-output name=dir::$(pip cache dir)"
40-
echo "::set-output name=date::$(/bin/date -u "+%m%Y")"
39+
echo "::set-output name=dir::$(pip cache dir)"
40+
echo "::set-output name=date::$(/bin/date -u "+%m%Y")"
4141
4242
- name: pip cache
4343
uses: actions/cache@v2
@@ -73,27 +73,31 @@ jobs:
7373
if: runner.os == 'Windows'
7474
uses: actions/cache@v2
7575
with:
76-
path: ${{ github.workspace }}\ManimCache
77-
key: ${{ runner.os }}-dependencies-ffmpeg-tinytex-${{ hashFiles('.github/manimdependency.json') }}-${{ steps.pip-cache-and-time.outputs.date }}
76+
path: ${{ github.workspace }}\ManimCache
77+
key: ${{ runner.os }}-dependencies-ffmpeg-tinytex-${{ hashFiles('.github/manimdependency.json') }}-${{ steps.pip-cache-and-time.outputs.date }}
7878

7979
- name: Download system dependencies (Windows)
8080
if: runner.os == 'Windows' && steps.cache-windows.outputs.cache-hit != 'true'
8181
run: |
8282
$ffmpegUrl = python -c "import json;print(json.load(open('.github/manimdependency.json'))['windows']['ffmpeg'])"
8383
$pangoVersion = python -c "import json;print(json.load(open('.github/manimdependency.json'))['windows']['pango'])"
84+
$tinyTexPackages = $(python -c "import json;print(' '.join(json.load(open('.github/manimdependency.json'))['windows']['tinytex']))") -Split ' '
8485
$OriPath = $env:PATH
8586
echo "Install Tinytex"
8687
Invoke-WebRequest "https://ci.appveyor.com/api/projects/yihui/tinytex/artifacts/TinyTeX.zip?job=image:%20Visual%20Studio%202019" -O "$($env:TMP)\TinyTex.zip"
8788
Expand-Archive -LiteralPath "$($env:TMP)\TinyTex.zip" -DestinationPath "$($PWD)\ManimCache\LatexWindows"
8889
$env:Path = "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\win32;$($env:PATH)"
8990
tlmgr update --self
90-
tlmgr install standalone preview doublestroke ms setspace rsfs relsize ragged2e fundus-calligra microtype wasysym physics dvisvgm jknapltx wasy cm-super babel-english
91+
foreach ($c in $tinyTexPackages){
92+
$c=$c.Trim()
93+
tlmgr install $c
94+
}
9195
$env:PATH=$OriPath
9296
echo "Completed Latex"
9397
Invoke-WebRequest "$ffmpegUrl" -O "$($env:TMP)\ffmpeg.zip"
9498
7z x "$($env:TMP)\ffmpeg.zip" -o"$($PWD)\ManimCache"
9599
Move-Item "ManimCache\ffmpeg-*" "ManimCache\FFmpeg"
96-
Invoke-WebRequest "https://github.com/ManimCommunity/manim-windows/releases/download/$($pangoVersion)/pango-windows-binaires-x64.zip" -O "$($env:TMP)\Pango.zip"
100+
Invoke-WebRequest "https://github.com/ManimCommunity/pango-windows-binaries/releases/download/$($pangoVersion)/pango-windows-binaires-x64.zip" -O "$($env:TMP)\Pango.zip"
97101
mkdir "$($PWD)\ManimCache\Pango"
98102
7z x "$($env:TMP)\Pango.zip" -o"$($PWD)\ManimCache\Pango"
99103
127 KB
Loading

docs/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Mobjects, Scenes, and Animations
6464
#. Add a :code:`Variable` class for displaying text that continuously updates to reflect the value of a python variable.
6565
#. The ``Tex`` and ``MathTex`` objects allow you to specify a custom TexTemplate using the ``template`` keyword argument.
6666
#. :code:`VGroup` now supports printing the class names of contained mobjects and :code:`VDict` supports printing the internal dict of mobjects
67+
#. Add all the standard easing functions
6768
#. :code:`Scene` now renders when :code:`Scene.render()` is called rather than upon instantiation.
6869
#. :code:`ValueTracker` now supports increment using the `+=` operator (in addition to the already existing `increment_value` method)
6970
#. Add :class:`PangoText` for rendering texts using Pango.

docs/source/examples.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ Examples
33

44
.. toctree::
55

6-
examples/shapes
6+
examples/shapes_images_positions
77
examples/annotations
88
examples/plots
9-
examples/text
9+
examples/tex
1010
examples/formulas
1111
examples/3d
1212
examples/camera_settings
1313
examples/animations
14-
examples/neat_projects
1514
examples/advanced_projects

docs/source/examples/3d.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2,
3333
checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
3434
)
35-
self.camera.light_source.move_to(3*IN) # changes the source of the light
35+
self.renderer.camera.light_source.move_to(3*IN) # changes the source of the light
3636
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
3737
self.add(axes, sphere)
3838

docs/source/examples/advanced_projects.rst

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,247 @@
11
Advanced Projects
22
=================================
33

4+
.. manim:: OpeningManimExample
5+
:quality: low
6+
7+
class OpeningManimExample(Scene):
8+
def construct(self):
9+
title = Tex("This is some \\LaTeX")
10+
basel = MathTex("\\sum_{n=1}^\\infty " "\\frac{1}{n^2} = \\frac{\\pi^2}{6}")
11+
VGroup(title, basel).arrange(DOWN)
12+
self.play(
13+
Write(title),
14+
FadeInFrom(basel, UP),
15+
)
16+
self.wait()
17+
18+
transform_title = Tex("That was a transform")
19+
transform_title.to_corner(UP + LEFT)
20+
self.play(
21+
Transform(title, transform_title),
22+
LaggedStart(*map(FadeOutAndShiftDown, basel)),
23+
)
24+
self.wait()
25+
26+
grid = NumberPlane()
27+
grid_title = Tex("This is a grid")
28+
grid_title.scale(1.5)
29+
grid_title.move_to(transform_title)
30+
31+
self.add(grid, grid_title) # Make sure title is on top of grid
32+
self.play(
33+
FadeOut(title),
34+
FadeInFromDown(grid_title),
35+
ShowCreation(grid, run_time=3, lag_ratio=0.1),
36+
)
37+
self.wait()
38+
39+
grid_transform_title = Tex(
40+
"That was a non-linear function \\\\" "applied to the grid"
41+
)
42+
grid_transform_title.move_to(grid_title, UL)
43+
grid.prepare_for_nonlinear_transform()
44+
self.play(
45+
grid.apply_function,
46+
lambda p: p
47+
+ np.array(
48+
[
49+
np.sin(p[1]),
50+
np.sin(p[0]),
51+
0,
52+
]
53+
),
54+
run_time=3,
55+
)
56+
self.wait()
57+
self.play(Transform(grid_title, grid_transform_title))
58+
self.wait()
59+
60+
61+
.. manim:: SquareToCircle
62+
:quality: low
63+
64+
class SquareToCircle(Scene):
65+
def construct(self):
66+
circle = Circle()
67+
square = Square()
68+
square.flip(RIGHT)
69+
square.rotate(-3 * TAU / 8)
70+
circle.set_fill(PINK, opacity=0.5)
71+
72+
self.play(ShowCreation(square))
73+
self.play(Transform(square, circle))
74+
self.play(FadeOut(square))
75+
76+
77+
.. manim:: WarpSquare
78+
:quality: low
79+
80+
class WarpSquare(Scene):
81+
def construct(self):
82+
square = Square()
83+
self.play(
84+
ApplyPointwiseFunction(
85+
lambda point: complex_to_R3(np.exp(R3_to_complex(point))), square
86+
)
87+
)
88+
self.wait()
89+
90+
.. manim:: WriteStuff
91+
:quality: low
92+
93+
class WriteStuff(Scene):
94+
def construct(self):
95+
example_text = Tex("This is a some text", tex_to_color_map={"text": YELLOW})
96+
example_tex = MathTex(
97+
"\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}",
98+
)
99+
group = VGroup(example_text, example_tex)
100+
group.arrange(DOWN)
101+
group.set_width(config["frame_width"] - 2 * LARGE_BUFF)
102+
103+
self.play(Write(example_text))
104+
self.play(Write(example_tex))
105+
self.wait()
106+
107+
.. manim:: UpdatersExample
108+
:quality: low
109+
110+
class UpdatersExample(Scene):
111+
def construct(self):
112+
decimal = DecimalNumber(
113+
0,
114+
show_ellipsis=True,
115+
num_decimal_places=3,
116+
include_sign=True,
117+
)
118+
square = Square().to_edge(UP)
119+
120+
decimal.add_updater(lambda d: d.next_to(square, RIGHT))
121+
decimal.add_updater(lambda d: d.set_value(square.get_center()[1]))
122+
self.add(square, decimal)
123+
self.play(
124+
square.to_edge,
125+
DOWN,
126+
rate_func=there_and_back,
127+
run_time=5,
128+
)
129+
self.wait()
130+
131+
132+
.. manim:: VDictExample
133+
:quality: low
134+
135+
class VDictExample(Scene):
136+
def construct(self):
137+
square = Square().set_color(RED)
138+
circle = Circle().set_color(YELLOW).next_to(square, UP)
139+
140+
# create dict from list of tuples each having key-mobject pair
141+
pairs = [("s", square), ("c", circle)]
142+
my_dict = VDict(pairs, show_keys=True)
143+
144+
# display it just like a VGroup
145+
self.play(ShowCreation(my_dict))
146+
self.wait()
147+
148+
text = Tex("Some text").set_color(GREEN).next_to(square, DOWN)
149+
150+
# add a key-value pair by wrapping it in a single-element list of tuple
151+
# after attrs branch is merged, it will be easier like `.add(t=text)`
152+
my_dict.add([("t", text)])
153+
self.wait()
154+
155+
rect = Rectangle().next_to(text, DOWN)
156+
# can also do key assignment like a python dict
157+
my_dict["r"] = rect
158+
159+
# access submobjects like a python dict
160+
my_dict["t"].set_color(PURPLE)
161+
self.play(my_dict["t"].scale, 3)
162+
self.wait()
163+
164+
# also supports python dict styled reassignment
165+
my_dict["t"] = Tex("Some other text").set_color(BLUE)
166+
self.wait()
167+
168+
# remove submoject by key
169+
my_dict.remove("t")
170+
self.wait()
171+
172+
self.play(Uncreate(my_dict["s"]))
173+
self.wait()
174+
175+
self.play(FadeOut(my_dict["c"]))
176+
self.wait()
177+
178+
self.play(FadeOutAndShift(my_dict["r"], DOWN))
179+
self.wait()
180+
181+
# you can also make a VDict from an existing dict of mobjects
182+
plain_dict = {
183+
1: Integer(1).shift(DOWN),
184+
2: Integer(2).shift(2 * DOWN),
185+
3: Integer(3).shift(3 * DOWN),
186+
}
187+
188+
vdict_from_plain_dict = VDict(plain_dict)
189+
vdict_from_plain_dict.shift(1.5 * (UP + LEFT))
190+
self.play(ShowCreation(vdict_from_plain_dict))
191+
192+
# you can even use zip
193+
vdict_using_zip = VDict(zip(["s", "c", "r"], [Square(), Circle(), Rectangle()]))
194+
vdict_using_zip.shift(1.5 * RIGHT)
195+
self.play(ShowCreation(vdict_using_zip))
196+
self.wait()
197+
198+
199+
.. manim:: VariableExample
200+
:quality: low
201+
202+
class VariableExample(Scene):
203+
def construct(self):
204+
var = 0.5
205+
on_screen_var = Variable(var, Text("var"), num_decimal_places=3)
206+
207+
# You can also change the colours for the label and value
208+
on_screen_var.label.set_color(RED)
209+
on_screen_var.value.set_color(GREEN)
210+
211+
self.play(Write(on_screen_var))
212+
# The above line will just display the variable with
213+
# its initial value on the screen. If you also wish to
214+
# update it, you can do so by accessing the `tracker` attribute
215+
self.wait()
216+
var_tracker = on_screen_var.tracker
217+
var = 10.5
218+
self.play(var_tracker.set_value, var)
219+
self.wait()
220+
221+
int_var = 0
222+
on_screen_int_var = Variable(
223+
int_var, Text("int_var"), var_type=Integer
224+
).next_to(on_screen_var, DOWN)
225+
on_screen_int_var.label.set_color(RED)
226+
on_screen_int_var.value.set_color(GREEN)
227+
228+
self.play(Write(on_screen_int_var))
229+
self.wait()
230+
var_tracker = on_screen_int_var.tracker
231+
var = 10.5
232+
self.play(var_tracker.set_value, var)
233+
self.wait()
234+
235+
# If you wish to have a somewhat more complicated label for your
236+
# variable with subscripts, superscripts, etc. the default class
237+
# for the label is MathTex
238+
subscript_label_var = 10
239+
on_screen_subscript_var = Variable(subscript_label_var, "{a}_{i}").next_to(
240+
on_screen_int_var, DOWN
241+
)
242+
self.play(Write(on_screen_subscript_var))
243+
self.wait()
244+
4245
.. manim:: ExampleSineCurve
5246

6247
class ExampleSineCurve(Scene):

docs/source/examples/neat_projects.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)