Skip to content

New examples #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0000ec8
Added kolibril python examples to the docs, re-formatted to be readable
MysaaJava Oct 19, 2020
cbbad12
Uniformisation of the examples names, but ... facing an issue
MysaaJava Oct 19, 2020
d896194
Whoops, i forgot to change the effective class names …
MysaaJava Oct 19, 2020
0bc665e
Fixed the ffmpeg empty partial movie file red error
MysaaJava Oct 20, 2020
133a032
Removed use of deprecated classes in the examples
MysaaJava Oct 20, 2020
5292fc8
Shortened the far too long message when no font is used, and about Ca…
MysaaJava Oct 20, 2020
1e32a0b
Fixing some docs building warnings
MysaaJava Oct 20, 2020
71050b7
Merge remote-tracking branch 'upstream/master' into newExamples
MysaaJava Oct 21, 2020
2e6da27
Taking kolibril review into account, changing the logo to the new one
MysaaJava Oct 21, 2020
b054005
Moving the ImageFromArray redundant example to reference and renaming…
MysaaJava Oct 21, 2020
a39ac3b
Merge remote-tracking branch 'origin/master' into newExamples
MysaaJava Oct 22, 2020
4ce9a05
Running black … again
MysaaJava Oct 22, 2020
a836ce3
Merge branch 'master' into newExamples
behackl Oct 22, 2020
1e71db4
Fixing documentation build errors, including the wrong logo url
MysaaJava Oct 22, 2020
8ce994a
Merge branch 'newExamples' of github.com:MysaaJava/manim into newExam…
MysaaJava Oct 22, 2020
0283b6f
Update docs/source/examples/3d.rst
MysaaJava Oct 22, 2020
4063d4b
No notes in the docs
MysaaJava Oct 22, 2020
7f7929c
Ran black on examples
MysaaJava Oct 22, 2020
21d6478
Ran black on examples
MysaaJava Oct 22, 2020
83a2acd
Reformatting examples
MysaaJava Oct 22, 2020
8845847
Apply suggestions from code review
MysaaJava Oct 22, 2020
c1057f3
I forgot this suggestion
MysaaJava Oct 22, 2020
fed1f72
Changing the reference URL to a file link, that will not depend on in…
MysaaJava Oct 22, 2020
0f2324f
Merge branch 'newExamples' of github.com:MysaaJava/manim into newExam…
MysaaJava Oct 22, 2020
9bb2a6c
Reset change to manim source code, to separate the PRs
MysaaJava Oct 24, 2020
bd1f507
Added docs to docstrings
MysaaJava Oct 24, 2020
1d0cdff
Truly reverting the changes
MysaaJava Oct 24, 2020
697fbc9
Removed the controversial of ImageMobject example with online file
MysaaJava Oct 24, 2020
425eebe
Merge branch 'master' into newExamples
MysaaJava Oct 24, 2020
5d26b66
Removed the ImageMobject example
MysaaJava Oct 24, 2020
838cd7f
Merge branch 'master' into newExamples
leotrs Oct 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/examples.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Example Gallery
============
===============

.. toctree::

Expand Down
71 changes: 61 additions & 10 deletions docs/source/examples/3d.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
3D Scenes
=================================

.. manim:: Example3DNo1
.. manim:: ThreeDSphere
:save_last_frame:

class Example3DNo1(ThreeDScene):
class ThreeDSphere(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
sphere = ParametricSurface(
Expand All @@ -18,10 +18,10 @@
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes, sphere)

.. manim:: Example3DLightSourcePosition
.. manim:: ThreeDLightSourcePosition
:save_last_frame:

class Example3DLightSourcePosition(ThreeDScene):
class ThreeDLightSourcePosition(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
sphere = ParametricSurface(
Expand All @@ -36,9 +36,9 @@
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes, sphere)

.. manim:: Example3DNo3
.. manim:: ThreeDCameraRotation

class Example3DNo3(ThreeDScene):
class ThreeDCameraRotation(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
circle=Circle()
Expand All @@ -50,9 +50,9 @@
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
self.wait()

.. manim:: Example3DNo4
.. manim:: ThreeDCameraIllusionRotation

class Example3DNo4(ThreeDScene):
class ThreeDCameraIllusionRotation(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
circle=Circle()
Expand All @@ -62,10 +62,10 @@
self.wait(PI)
self.stop_3dillusion_camera_rotation()

.. manim:: Example3DNo5
.. manim:: ThreeDParametricSpring
:save_last_frame:

class Example3DNo5(ThreeDScene):
class ThreeDParametricSpring(ThreeDScene):
def construct(self):
curve1 = ParametricFunction(
lambda u: np.array([
Expand All @@ -79,3 +79,54 @@
self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES)
self.wait()

.. manim:: ThreeDFunctionPlot

class ThreeDFunctionPlot(ThreeDScene):
def construct(self):
resolution_fa = 22
self.set_camera_orientation(phi=75 * DEGREES, theta=-30 * DEGREES)

def param_plane(u, v):
x = u
y = v
z = 0
return np.array([x, y, z])

plane = ParametricSurface(
param_plane,
resolution=(resolution_fa, resolution_fa),
v_min=-2,
v_max=+2,
u_min=-2,
u_max=+2,
)
plane.scale_about_point(2, ORIGIN)

def param_gauss(u, v):
x = u
y = v
d = np.sqrt(x * x + y * y)
sigma, mu = 0.4, 0.0
z = np.exp(-((d - mu) ** 2 / (2.0 * sigma ** 2)))
return np.array([x, y, z])

gauss_plane = ParametricSurface(
param_gauss,
resolution=(resolution_fa, resolution_fa),
v_min=-2,
v_max=+2,
u_min=-2,
u_max=+2,
)

gauss_plane.scale_about_point(2, ORIGIN)
gauss_plane.set_style(fill_opacity=1)
gauss_plane.set_style(stroke_color=GREEN)
gauss_plane.set_fill_by_checkerboard(GREEN, BLUE, opacity=0.1)

axes = ThreeDAxes()

self.add(axes)
self.play(Write(plane))
self.play(Transform(plane, gauss_plane))
self.wait()
24 changes: 12 additions & 12 deletions docs/source/examples/advanced_projects.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Advanced Projects
=================================

.. manim:: OpeningManimExample
.. manim:: OpeningManim
:ref_classes: Tex MathTex NumberPlane

class OpeningManimExample(Scene):
class OpeningManim(Scene):
def construct(self):
title = Tex("This is some \\LaTeX")
basel = MathTex("\\sum_{n=1}^\\infty " "\\frac{1}{n^2} = \\frac{\\pi^2}{6}")
Expand All @@ -19,7 +19,7 @@ Advanced Projects
transform_title.to_corner(UP + LEFT)
self.play(
Transform(title, transform_title),
LaggedStart(*map(FadeOutAndShiftDown, basel)),
LaggedStart(*map(lambda obj: FadeOutAndShift(obj, direction=DOWN), basel)),
)
self.wait()

Expand All @@ -31,7 +31,7 @@ Advanced Projects
self.add(grid, grid_title) # Make sure title is on top of grid
self.play(
FadeOut(title),
FadeInFromDown(grid_title),
FadeInFrom(grid_title, direction=DOWN),
ShowCreation(grid, run_time=3, lag_ratio=0.1),
)
self.wait()
Expand Down Expand Up @@ -104,10 +104,10 @@ Advanced Projects
self.play(Write(example_tex))
self.wait()

.. manim:: UpdatersExample
.. manim:: SquareMovingWithUpdaters
:quality: low

class UpdatersExample(Scene):
class SquareMovingWithUpdaters(Scene):
def construct(self):
decimal = DecimalNumber(
0,
Expand All @@ -129,10 +129,10 @@ Advanced Projects
self.wait()


.. manim:: VDictExample
.. manim:: ShapesWithVDics
:quality: low

class VDictExample(Scene):
class ShapesWithVDics(Scene):
def construct(self):
square = Square().set_color(RED)
circle = Circle().set_color(YELLOW).next_to(square, UP)
Expand Down Expand Up @@ -196,10 +196,10 @@ Advanced Projects
self.wait()


.. manim:: VariableExample
.. manim:: VariablesWithValueTracker
:quality: low

class VariableExample(Scene):
class VariablesWithValueTracker(Scene):
def construct(self):
var = 0.5
on_screen_var = Variable(var, Text("var"), num_decimal_places=3)
Expand Down Expand Up @@ -242,9 +242,9 @@ Advanced Projects
self.play(Write(on_screen_subscript_var))
self.wait()

.. manim:: ExampleSineCurve
.. manim:: SineCurvePlot

class ExampleSineCurve(Scene):
class SineCurvePlot(Scene):
# contributed by heejin_park, https://infograph.tistory.com/230
def construct(self):
self.show_axis()
Expand Down
61 changes: 48 additions & 13 deletions docs/source/examples/animations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Some more examples will come soon here!
Updaters
##########

.. manim:: Updater1Example
.. manim:: RotationUpdater

class Updater1Example(Scene):
class RotationUpdater(Scene):
def construct(self):
def my_rotation_updater(mobj,dt):
mobj.rotate_about_origin(dt)
Expand All @@ -22,9 +22,9 @@ Updaters
self.add(line_reference, line_moving)
self.wait(PI)

.. manim:: Updater2Example
.. manim:: RotationUpdater2

class Updater2Example(Scene):
class RotationUpdater2(Scene):
def construct(self):
def updater_forth(mobj, dt):
mobj.rotate_about_origin(dt)
Expand All @@ -41,9 +41,9 @@ Updaters
line_moving.remove_updater(updater_back)
self.wait(0.5)

.. manim:: Example3
.. manim:: NumberLinePointer

class Example3(Scene):
class NumberLinePointer(Scene):
def construct(self):
number_line = NumberLine() ##with all your parameters and stuff
pointer = Vector(DOWN)
Expand All @@ -57,10 +57,11 @@ Updaters
self.play(pointer_value.set_value, 5)
self.wait()
self.play(pointer_value.set_value, 3)
self.wait()

.. manim:: Example4
.. manim:: PointWithTrace

class Example4(Scene):
class PointWithTrace(Scene):
def construct(self):
path = VMobject()
dot = Dot()
Expand All @@ -77,9 +78,9 @@ Updaters
self.play(dot.shift, LEFT)
self.wait()

.. manim:: Example1ValTracker
.. manim:: PointMovingWithValTracker

class Example1ValTracker(Scene):
class PointMovingWithValTracker(Scene):
def construct(self):
dot_disp = Dot().set_color(RED)
self.add(dot_disp)
Expand All @@ -92,9 +93,9 @@ Updaters
self.play(val_tracker.set_value, tick_end, rate_func=linear)
self.wait()

.. manim:: Example2ValTracker
.. manim:: RotationValTracker

class Example2ValTracker(Scene):
class RotationValTracker(Scene):
def construct(self):
tick_start = 0
tick_end = 2 * PI
Expand All @@ -105,4 +106,38 @@ Updaters
line_moving = Line(ORIGIN, LEFT).set_color(ORANGE)
line_moving.add_updater(my_rotation_updater)
self.add(line_reference, line_moving)
self.play(val_tracker.set_value, tick_end, run_time=PI)
self.play(val_tracker.set_value, tick_end, run_time=PI)

.. manim:: PlaneFadeOut

class PlaneFadeOut(Scene):
def construct(self):
sq2 = Square()

sq1 = Square()
sq1.next_to(sq2, LEFT)

sq3 = Square()
sq3.next_to(sq2, RIGHT)

circ = Circle()
circ.next_to(sq2, DOWN)

self.add(sq1, sq2, sq3, circ)
self.wait()

self.play(FadeOut(sq1), FadeOut(sq2), FadeOut(sq3))
self.wait()

.. manim:: FadeInAndOut

class FadeInAndOut(Scene):
def construct(self):
square = Square(color=BLUE).shift(2 * UP)
annotation = Text("Fade In", height=0.8)
self.add(annotation)
self.play(FadeIn(square))

annotation.become(Text("Fade Out", height=0.8))
self.add(annotation)
self.play(FadeOut(square))
16 changes: 8 additions & 8 deletions docs/source/examples/annotations.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Annotations
=================================

.. manim:: AnnotateBrace
.. manim:: BraceAnnotation
:save_last_frame:

class AnnotateBrace(Scene):
class BraceAnnotation(Scene):
def construct(self):
dot = Dot([0, 0, 0])
dot2 = Dot([2, 1, 0])
Expand All @@ -15,26 +15,26 @@ Annotations
b2text = b2.get_tex("x-x_1")
self.add(dot, dot2, line, b1, b2, b1text, b2text)

.. manim:: ExampleArrow
.. manim:: VectorArrow
:quality: medium
:save_last_frame:

class ExampleArrow(Scene):
class VectorArrow(Scene):
def construct(self):
dot = Dot(ORIGIN)
arrow = Arrow(ORIGIN, [2, 2, 0], buff=0)
numberplane = NumberPlane()
origin_text = TextMobject('(0, 0)').next_to(dot, DOWN)
tip_text = TextMobject('(2, 2)').next_to(arrow.get_end(), RIGHT)
origin_text = Text('(0, 0)').next_to(dot, DOWN)
tip_text = Text('(2, 2)').next_to(arrow.get_end(), RIGHT)
self.add(numberplane, dot, arrow, origin_text, tip_text)

.. manim:: ExampleArrowTips
.. manim:: ArrowTipsShowcase
:quality: medium
:save_last_frame:

from manim.mobject.geometry import ArrowTriangleTip, ArrowSquareTip, ArrowSquareFilledTip,\
ArrowCircleTip, ArrowCircleFilledTip
class ExampleArrowTips(Scene):
class ArrowTipsShowcase(Scene):
def construct(self):
a00 = Arrow(start=[-2, 3, 0], end=[2, 3, 0], color=YELLOW)
a11 = Arrow(start=[-2, 2, 0], end=[2, 2, 0], tip_shape=ArrowTriangleTip)
Expand Down
Loading