manim

Run Settings
LanguagePython
Language Version
Run Command
print("Hello World!") # git clone https://github.com/3b1b/manim.git # cd manim pip install -e . manimgl example_scenes.py OpeningManimExample
%%manim -qm CircleToSquare class CircleToSquare(Scene): def construct(self): heart = ( ParametricFunction( lambda t: np.array( [ 16 * np.sin(t) ** 3, 13 * np.cos(t) - 5 * np.cos(2 * t) - 2 * np.cos(3 * t) - np.cos(4 * t), 0, ] ), t_range=[0, TAU, 0.01], color=PINK, ) .scale(0.1) .shift(UP * 2) ) self.play(Create(heart, run_time=2)) self.play(heart.animate.scale(1.2), rate_func=there_and_back) self.play(heart.animate.scale(1.5), rate_func=there_and_back) self.play(heart.animate.scale(1.2), rate_func=there_and_back)
class HelloCircle(Scene): def construct(self): var = 10.5 on_screen_var = Variable(var, Text("var"), num_decimal_places=3) # You can also change the colours for the label and value on_screen_var.label.set_color(RED) on_screen_var.value.set_color(GREEN) self.play(Write(on_screen_var)) # The above line will just display the variable with # its initial value on the screen. If you also wish to # update it, you can do so by accessing the `tracker` attribute self.wait() var_tracker = on_screen_var.tracker var = 11.781 self.play(var_tracker.animate.set_value(var)) self.wait() var = 10.384 self.play(var_tracker.animate.set_value(var)) self.wait() int_var = 13.1 on_screen_int_var = Variable( int_var, Text("int_var"), var_type=Integer ).next_to(on_screen_var, DOWN) on_screen_int_var.label.set_color(RED) on_screen_int_var.value.set_color(GREEN) self.play(Write(on_screen_int_var)) self.wait() var_tracker = on_screen_int_var.tracker var = 3.5 self.play(var_tracker.animate.set_value(var)) self.wait() # If you wish to have a somewhat more complicated label for your # variable with subscripts, superscripts, etc. the default class # for the label is MathTex subscript_label_var = 10 on_screen_subscript_var = Variable(subscript_label_var, "{a}_{i}").next_to( on_screen_int_var, DOWN ) self.play(Write(on_screen_subscript_var)) self.wait()
class MyClass: @staticmethod def static_method(): print("This is a static method.") @classmethod def class_method(cls): print(f"This is a class method of {cls.__name__}.") @property def name(self): return self._name @name.setter def name(self, value): self._name = value # 使用 MyClass.static_method() MyClass.class_method() obj = MyClass() obj.name = "Alice" print(obj.name)
Editor Settings
Theme
Key bindings
Full width
Lines