This interactive worksheet contains an overview over the new features contained in the latest release of the community maintained version of Manim.
from manim import *
config.media_width = "80%"
With the new set_default
method it is easy to change default arguments for mobjects. For example, Text.set_default(color=RED)
changes the default color of Text
to red:
%%manim -qm -v WARNING ChangedDefaultDemo
class ChangedDefaultDemo(Scene):
def construct(self):
Text.set_default(color=BLUE)
t = Text("This is blue text, magic!")
# You can also change multiple arguments at once:
Circle.set_default(color=GREEN, fill_opacity=0.5)
c = Circle()
VGroup(t, c).arrange(DOWN)
self.add(t, c)
# Call the method without arguments to restore the default behavior!
Text.set_default()
Circle.set_default()
ImplicitFunction?
%%manim -qm -v WARNING ImplicitFunctionDemo
import numpy as np
class ImplicitFunctionDemo(Scene):
def construct(self):
plane = NumberPlane()
curve = ImplicitFunction(
lambda x, y: (x**2 + y**2)**2 - 42*(x**2 - y**2),
color=YELLOW,
max_quads=2000,
)
self.add(plane)
self.play(Create(curve))
self.wait()
elliptic_curve = ImplicitFunction(
lambda x, y: x**3 - x + 1 - y**2,
color=RED,
)
self.play(Create(elliptic_curve))
self.wait()
%%manim -qm -v WARNING BooleanOperationDemo
class BooleanOperationDemo(Scene):
def construct(self):
VMobject.set_default(color=GREEN, fill_opacity=0.5)
Circle.set_default(radius=2, fill_opacity=0.5)
c1 = Circle(color=YELLOW).shift(LEFT)
c2 = Circle(color=BLUE).shift(RIGHT)
circles = VGroup(c1, c2)
self.add(circles.scale(0.5))
# Note: changing the default color and fill opacity for VMobject also affects subclasses
# like Union, Intersection, Difference, and Exclusion.
grid = VGroup(
Union(c1, c2),
Intersection(c1, c2),
Difference(c1, c2),
Exclusion(c1, c2)
).arrange_in_grid(2, 2, buff=3)
self.add(grid)
VMobject.set_default()
Circle.set_default()
When passing a z_range
parameter to ArrowVectorField
or StreamLines
, the vector field will be rendered in three dimensions. Note: this example takes a bit longer to render.
%%manim -qm -v WARNING --disable_caching ThreeDArrowVectorField
class ThreeDArrowVectorField(ThreeDScene):
def construct(self):
def func(p):
return np.cross(p, np.array([0, 0, p[2]]))
vector_field = ArrowVectorField(
func,
x_range=[-2.5, 2.5, 1],
y_range=[-2.5, 2.5, 1],
z_range=[-1.5, 1.5, 1],
)
particle = Dot3D(OUT + RIGHT * 2)
self.add(vector_field, particle)
particle.add_updater(vector_field.get_nudge_updater(2))
self.move_camera(PI/3, -PI/4, run_time=3)
stream_lines = StreamLines(
func,
x_range=[-2.5, 2.5, 1.5],
y_range=[-2.5, 2.5, 1.5],
z_range=[-1.5, 1.5, 1.5],
)
self.play(FadeTransform(vector_field, stream_lines), run_time=0.5)
self.wait()
To find out more about the exciting new features, fixed bugs, deprecated functions, and other improvements made in Manim v0.11.0, check out the full changelog at https://docs.manim.community/en/stable/changelog/0.11.0-changelog.html. Enjoy manimating!