Skip to content

Commit 58469dc

Browse files
committed
Merge branch 'master' of https://github.com/manimcommunity/manim into pango-text
2 parents 7cefdee + 2002145 commit 58469dc

Some content is hidden

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

60 files changed

+1320
-450
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
Invoke-WebRequest "https://ci.appveyor.com/api/projects/yihui/tinytex/artifacts/TinyTeX.zip?job=image:%20Visual%20Studio%202019" -O "$($env:TMP)\TinyTex.zip"
8989
Expand-Archive -LiteralPath "$($env:TMP)\TinyTex.zip" -DestinationPath "$($PWD)\ManimCache\LatexWindows"
9090
$env:Path = "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\win32;$($env:PATH)"
91+
tlmgr update --self
9192
tlmgr install standalone preview doublestroke ms setspace rsfs relsize ragged2e fundus-calligra microtype wasysym physics dvisvgm jknapltx wasy cm-super babel-english
9293
$env:PATH=$OriPath
9394
echo "Completed Latex Install Sox"

docs/source/changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ Mobjects, Scenes, and Animations
6060
#. The :code:`Container` class has been made into an AbstractBaseClass, i.e. in cannot be instantiated. Instead, use one of its children classes
6161
#. The ``TextMobject`` and ``TexMobject`` objects have been deprecated, due to their confusing names, in favour of ``Tex`` and ``MathTex``. You can still, however, continue to use ``TextMobject`` and ``TexMobject``, albeit with Deprecation Warnings constantly reminding you to switch.
6262
#. Add a :code:`Variable` class for displaying text that continuously updates to reflect the value of a python variable.
63-
#. Add ``PangoText`` for rendering texts using Pango.
63+
#. The ``Tex`` and ``MathTex`` objects allow you to specify a custom TexTemplate using the ``template`` keyword argument.
64+
#. :code:`VGroup` now supports printing the class names of contained mobjects and :code:`VDict` supports printing the internal dict of mobjects
65+
#. Add :class:`PangoText` for rendering texts using Pango.
6466

6567

6668
Documentation
@@ -92,6 +94,7 @@ Of interest to developers
9294
#. Added logging tests tools.
9395
#. Added ability to save logs in json
9496
#. Move to Poetry.
97+
#. Colors have moved to an Enum
9598

9699
Other Changes
97100
--------------

docs/source/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ Examples
1212
examples/camera_settings
1313
examples/animations
1414
examples/neat_projects
15-
examples/advanced_projects
15+
examples/advanced_projects

docs/source/examples/3d.rst

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
=================================
33

44
.. manim:: Example3DNo1
5-
:quality: medium
65
:save_last_frame:
76

87
class Example3DNo1(ThreeDScene):
@@ -19,3 +18,64 @@
1918
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
2019
self.add(axes, sphere)
2120

21+
.. manim:: Example3DLightSourcePosition
22+
:save_last_frame:
23+
24+
class Example3DLightSourcePosition(ThreeDScene):
25+
def construct(self):
26+
axes = ThreeDAxes()
27+
sphere = ParametricSurface(
28+
lambda u, v: np.array([
29+
1.5 * np.cos(u) * np.cos(v),
30+
1.5 * np.cos(u) * np.sin(v),
31+
1.5 * np.sin(u)
32+
]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2,
33+
checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
34+
)
35+
self.camera.light_source.move_to(3*IN) # changes the source of the light
36+
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
37+
self.add(axes, sphere)
38+
39+
.. manim:: Example3DNo3
40+
41+
class Example3DNo3(ThreeDScene):
42+
def construct(self):
43+
axes = ThreeDAxes()
44+
circle=Circle()
45+
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
46+
self.add(circle,axes)
47+
self.begin_ambient_camera_rotation(rate=0.1)
48+
self.wait(3)
49+
self.stop_ambient_camera_rotation()
50+
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
51+
self.wait()
52+
53+
.. manim:: Example3DNo4
54+
55+
class Example3DNo4(ThreeDScene):
56+
def construct(self):
57+
axes = ThreeDAxes()
58+
circle=Circle()
59+
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
60+
self.add(circle,axes)
61+
self.begin_3dillusion_camera_rotation(rate=2)
62+
self.wait(PI)
63+
self.stop_3dillusion_camera_rotation()
64+
65+
.. manim:: Example3DNo5
66+
:save_last_frame:
67+
68+
class Example3DNo5(ThreeDScene):
69+
def construct(self):
70+
curve1 = ParametricFunction(
71+
lambda u: np.array([
72+
1.2 * np.cos(u),
73+
1.2 * np.sin(u),
74+
u * 0.05
75+
]), color=RED, t_min=-3 * TAU, t_max=5 * TAU,
76+
).set_shade_in_3d(True)
77+
axes = ThreeDAxes()
78+
self.add(axes, curve1)
79+
self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES)
80+
self.wait()
81+
Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,91 @@
11
Advanced Projects
22
=================================
33

4-
This page is currently under construction. It will feature a selection of advanced projects built with manim.
4+
.. manim:: ExampleSineCurve
5+
6+
class ExampleSineCurve(Scene):
7+
# contributed by heejin_park, https://infograph.tistory.com/230
8+
def construct(self):
9+
self.show_axis()
10+
self.show_circle()
11+
self.move_dot_and_draw_curve()
12+
self.wait()
13+
14+
def show_axis(self):
15+
x_start = np.array([-6,0,0])
16+
x_end = np.array([6,0,0])
17+
18+
y_start = np.array([-4,-2,0])
19+
y_end = np.array([-4,2,0])
20+
21+
x_axis = Line(x_start, x_end)
22+
y_axis = Line(y_start, y_end)
23+
24+
self.add(x_axis, y_axis)
25+
self.add_x_labels()
26+
27+
self.orgin_point = np.array([-4,0,0])
28+
self.curve_start = np.array([-3,0,0])
29+
30+
def add_x_labels(self):
31+
x_labels = [
32+
TexMobject("\pi"), TexMobject("2 \pi"),
33+
TexMobject("3 \pi"), TexMobject("4 \pi"),
34+
]
35+
36+
for i in range(len(x_labels)):
37+
x_labels[i].next_to(np.array([-1 + 2*i, 0, 0]), DOWN)
38+
self.add(x_labels[i])
39+
40+
def show_circle(self):
41+
circle = Circle(radius=1)
42+
circle.move_to(self.orgin_point)
43+
44+
self.add(circle)
45+
self.circle = circle
46+
47+
def move_dot_and_draw_curve(self):
48+
orbit = self.circle
49+
orgin_point = self.orgin_point
50+
51+
dot = Dot(radius=0.08, color=YELLOW)
52+
dot.move_to(orbit.point_from_proportion(0))
53+
self.t_offset = 0
54+
rate = 0.25
55+
56+
def go_around_circle(mob, dt):
57+
self.t_offset += (dt * rate)
58+
# print(self.t_offset)
59+
mob.move_to(orbit.point_from_proportion(self.t_offset % 1))
60+
61+
def get_line_to_circle():
62+
return Line(orgin_point, dot.get_center(), color=BLUE)
63+
64+
def get_line_to_curve():
65+
x = self.curve_start[0] + self.t_offset * 4
66+
y = dot.get_center()[1]
67+
return Line(dot.get_center(), np.array([x,y,0]), color=YELLOW_A, stroke_width=2 )
68+
69+
70+
self.curve = VGroup()
71+
self.curve.add(Line(self.curve_start,self.curve_start))
72+
def get_curve():
73+
last_line = self.curve[-1]
74+
x = self.curve_start[0] + self.t_offset * 4
75+
y = dot.get_center()[1]
76+
new_line = Line(last_line.get_end(),np.array([x,y,0]), color=YELLOW_D)
77+
self.curve.add(new_line)
78+
79+
return self.curve
80+
81+
dot.add_updater(go_around_circle)
82+
83+
origin_to_circle_line = always_redraw(get_line_to_circle)
84+
dot_to_curve_line = always_redraw(get_line_to_curve)
85+
sine_curve_line = always_redraw(get_curve)
86+
87+
self.add(dot)
88+
self.add(orbit, origin_to_circle_line, dot_to_curve_line, sine_curve_line)
89+
self.wait(8.5)
90+
91+
dot.remove_updater(go_around_circle)

docs/source/examples/animations.rst

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,98 @@ Updaters
1111
##########
1212

1313
.. manim:: Updater1Example
14-
:quality: medium
1514

1615
class Updater1Example(Scene):
1716
def construct(self):
18-
curve_reference = Line(ORIGIN, LEFT).set_color(GREEN)
19-
self.add(curve_reference)
17+
def my_rotation_updater(mobj,dt):
18+
mobj.rotate_about_origin(dt)
19+
line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
20+
line_moving = Line(ORIGIN, LEFT).set_color(BLUE)
21+
line_moving.add_updater(my_rotation_updater)
22+
self.add(line_reference, line_moving)
23+
self.wait(PI)
2024

21-
def update_curve(mob, dt):
22-
mob.rotate_about_origin(dt)
25+
.. manim:: Updater2Example
2326

24-
curve2 = Line(ORIGIN, LEFT)
25-
curve2.add_updater(update_curve)
26-
self.add(curve_reference, curve2)
27-
self.wait(PI)
27+
class Updater2Example(Scene):
28+
def construct(self):
29+
def updater_forth(mobj, dt):
30+
mobj.rotate_about_origin(dt)
31+
def updater_back(mobj, dt):
32+
mobj.rotate_about_origin(-dt)
33+
line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
34+
line_moving = Line(ORIGIN, LEFT).set_color(YELLOW)
35+
line_moving.add_updater(updater_forth)
36+
self.add(line_reference, line_moving)
37+
self.wait(2)
38+
line_moving.remove_updater(updater_forth)
39+
line_moving.add_updater(updater_back)
40+
self.wait(2)
41+
line_moving.remove_updater(updater_back)
42+
self.wait(0.5)
43+
44+
.. manim:: Example3
45+
46+
class Example3(Scene):
47+
def construct(self):
48+
number_line = NumberLine() ##with all your parameters and stuff
49+
pointer = Vector(DOWN)
50+
label = MathTex("x").add_updater(lambda m: m.next_to(pointer, UP))
51+
52+
pointer_value = ValueTracker(0)
53+
pointer.add_updater(
54+
lambda m: m.next_to( number_line.n2p(pointer_value.get_value()), UP)
55+
)
56+
self.add(number_line, pointer, label)
57+
self.play(pointer_value.set_value, 5)
58+
self.wait()
59+
self.play(pointer_value.set_value, 3)
60+
61+
.. manim:: Example4
62+
63+
class Example4(Scene):
64+
def construct(self):
65+
path = VMobject()
66+
dot = Dot()
67+
path.set_points_as_corners([dot.get_center(), dot.get_center()])
68+
def update_path(path):
69+
previus_path = path.copy()
70+
previus_path.add_points_as_corners([dot.get_center()])
71+
path.become(previus_path)
72+
path.add_updater(update_path)
73+
self.add(path, dot)
74+
self.play(Rotating(dot, radians=PI, about_point=RIGHT, run_time=2))
75+
self.wait()
76+
self.play(dot.shift, UP)
77+
self.play(dot.shift, LEFT)
78+
self.wait()
79+
80+
.. manim:: Example1ValTracker
81+
82+
class Example1ValTracker(Scene):
83+
def construct(self):
84+
dot_disp = Dot().set_color(RED)
85+
self.add(dot_disp)
86+
tick_start = 1
87+
tick_end = 2
88+
val_tracker = ValueTracker(tick_start)
89+
def dot_updater(mob):
90+
mob.set_y(val_tracker.get_value())
91+
dot_disp.add_updater(dot_updater)
92+
self.play(val_tracker.set_value, tick_end, rate_func=linear)
93+
self.wait()
94+
95+
.. manim:: Example2ValTracker
96+
97+
class Example2ValTracker(Scene):
98+
def construct(self):
99+
tick_start = 0
100+
tick_end = 2 * PI
101+
val_tracker = ValueTracker(tick_start)
102+
def my_rotation_updater(mobj):
103+
mobj.rotate_about_origin(1 / 30) # be careful: This is framerate dependent!
104+
line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
105+
line_moving = Line(ORIGIN, LEFT).set_color(ORANGE)
106+
line_moving.add_updater(my_rotation_updater)
107+
self.add(line_reference, line_moving)
108+
self.play(val_tracker.set_value, tick_end, run_time=PI)

docs/source/examples/annotations.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Annotations
22
=================================
33

44
.. manim:: AnnotateBrace
5-
:quality: medium
65
:save_last_frame:
76

87
class AnnotateBrace(Scene):

0 commit comments

Comments
 (0)