mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Merge pull request #154 from 3b1b/winding-number-grant
Winding number grant
This commit is contained in:
commit
72defba803
78 changed files with 700 additions and 260 deletions
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
@ -31,7 +32,7 @@ from topics.graph_scene import *
|
|||
|
||||
from active_projects.WindingNumber import *
|
||||
|
||||
class AltTeacherStudentScene(TeacherStudentsScene):
|
||||
class AltTeacherStudentsScene(TeacherStudentsScene):
|
||||
def setup(self):
|
||||
TeacherStudentsScene.setup(self)
|
||||
self.teacher.set_color(YELLOW_E)
|
||||
|
@ -39,24 +40,34 @@ class AltTeacherStudentScene(TeacherStudentsScene):
|
|||
###############
|
||||
|
||||
|
||||
class TestColorMap(ColorMappedObjectsScene):
|
||||
class IntroSceneWrapper(PiCreatureScene):
|
||||
CONFIG = {
|
||||
"func" : example_plane_func,
|
||||
"default_pi_creature_kwargs" : {
|
||||
"color" : YELLOW_E,
|
||||
"flip_at_start" : False,
|
||||
"height" : 2,
|
||||
},
|
||||
"default_pi_creature_start_corner" : DOWN+LEFT,
|
||||
# "default_pi_creature_height" : 1,
|
||||
}
|
||||
def construct(self):
|
||||
ColorMappedObjectsScene.construct(self)
|
||||
circle = Circle(color = WHITE)
|
||||
circle.color_using_background_image(self.background_image_file)
|
||||
morty = self.pi_creature
|
||||
rect = ScreenRectangle(height = 5)
|
||||
rect.to_corner(UP+RIGHT)
|
||||
self.add(rect)
|
||||
|
||||
self.play(ShowCreation(circle))
|
||||
self.play(circle.scale, 2)
|
||||
self.wait()
|
||||
self.play(circle.set_fill, {"opacity" : 0.2})
|
||||
for corner in standard_rect:
|
||||
self.play(circle.to_corner, corner, run_time = 2)
|
||||
main_topic, meta_topic = toipcs = VGroup(
|
||||
TextMobject("Main topic"),
|
||||
TextMobject("Meta topic"),
|
||||
)
|
||||
topics.arrange_submobjects(DOWN, aligned_edge = LEFT)
|
||||
|
||||
|
||||
class PiCreaturesAreIntrigued(AltTeacherStudentScene):
|
||||
|
||||
|
||||
|
||||
|
||||
class PiCreaturesAreIntrigued(AltTeacherStudentsScene):
|
||||
def construct(self):
|
||||
self.teacher_says(
|
||||
"You can extend \\\\ this to 2d",
|
||||
|
@ -66,7 +77,7 @@ class PiCreaturesAreIntrigued(AltTeacherStudentScene):
|
|||
self.look_at(self.screen)
|
||||
self.wait(3)
|
||||
|
||||
class RewriteEquationWithTeacher(AltTeacherStudentScene):
|
||||
class RewriteEquationWithTeacher(AltTeacherStudentsScene):
|
||||
def construct(self):
|
||||
equations = VGroup(
|
||||
TexMobject(
|
||||
|
@ -114,8 +125,16 @@ class RewriteEquationWithTeacher(AltTeacherStudentScene):
|
|||
dot.fade(1)
|
||||
dot.center()
|
||||
|
||||
question = TextMobject(
|
||||
"Wait...what would \\\\", "+", "and", "\\textminus", " \\, be in 2d?",
|
||||
)
|
||||
question.highlight_by_tex_to_color_map({
|
||||
"+" : "green",
|
||||
"textminus" : "red"
|
||||
})
|
||||
|
||||
self.student_says(
|
||||
"Wait...what would \\\\ + and \\textminus \\, be in 2d?",
|
||||
question,
|
||||
target_mode = "sassy",
|
||||
student_index = 2,
|
||||
added_anims = [
|
||||
|
@ -123,6 +142,7 @@ class RewriteEquationWithTeacher(AltTeacherStudentScene):
|
|||
self.teacher.change, "plain",
|
||||
],
|
||||
bubble_kwargs = {"direction" : LEFT},
|
||||
run_time = 1,
|
||||
)
|
||||
self.play(
|
||||
Write(plane, run_time = 1),
|
||||
|
@ -135,12 +155,341 @@ class RewriteEquationWithTeacher(AltTeacherStudentScene):
|
|||
self.play(dot.move_to, plane.coords_to_point(*coords))
|
||||
self.wait()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class DotsHoppingToColor(Scene):
|
||||
CONFIG = {
|
||||
"dot_radius" : 0.05,
|
||||
"plane_width" : 6,
|
||||
"plane_height" : 6,
|
||||
"x_shift" : SPACE_WIDTH/2,
|
||||
"y_shift" : MED_LARGE_BUFF,
|
||||
"output_scalar" : 10,
|
||||
"non_renormalized_func" : plane_func_by_wind_spec(
|
||||
(-2, -1, 2),
|
||||
(1, 2, 1),
|
||||
(2, -2, 1),
|
||||
),
|
||||
"dot_density" : 0.25,
|
||||
}
|
||||
def construct(self):
|
||||
input_coloring, output_coloring = self.get_colorings()
|
||||
input_plane, output_plane = self.get_planes()
|
||||
|
||||
v_line = Line(UP, DOWN).scale(SPACE_HEIGHT)
|
||||
v_line.set_stroke(WHITE, 5)
|
||||
|
||||
dots = self.get_dots(input_plane, output_plane)
|
||||
|
||||
right_half_block = Rectangle(
|
||||
height = 2*SPACE_HEIGHT,
|
||||
width = SPACE_WIDTH - SMALL_BUFF,
|
||||
stroke_width = 0,
|
||||
fill_color = BLACK,
|
||||
fill_opacity = 0.8,
|
||||
)
|
||||
right_half_block.to_edge(RIGHT, buff = 0)
|
||||
|
||||
#Introduce parts
|
||||
self.add(input_plane, output_plane, v_line)
|
||||
self.play(
|
||||
FadeIn(output_coloring),
|
||||
Animation(output_plane),
|
||||
output_plane.white_parts.highlight, BLACK,
|
||||
output_plane.lines_to_fade.set_stroke, {"width" : 0},
|
||||
)
|
||||
self.wait()
|
||||
self.play(LaggedStart(GrowFromCenter, dots, run_time = 3))
|
||||
self.wait()
|
||||
|
||||
#Hop over and back
|
||||
self.play(LaggedStart(
|
||||
MoveToTarget, dots,
|
||||
path_arc = -TAU/4,
|
||||
run_time = 3,
|
||||
))
|
||||
self.wait()
|
||||
self.play(LaggedStart(
|
||||
ApplyMethod, dots,
|
||||
lambda d : (d.set_fill, d.target_color),
|
||||
))
|
||||
self.wait()
|
||||
self.play(LaggedStart(
|
||||
ApplyMethod, dots,
|
||||
lambda d : (d.move_to, d.original_position),
|
||||
path_arc = TAU/4,
|
||||
run_time = 3,
|
||||
))
|
||||
self.wait()
|
||||
self.play(
|
||||
FadeIn(input_coloring),
|
||||
Animation(input_plane),
|
||||
input_plane.white_parts.highlight, BLACK,
|
||||
input_plane.lines_to_fade.set_stroke, {"width" : 0},
|
||||
FadeOut(dots),
|
||||
)
|
||||
self.wait()
|
||||
|
||||
#Cover output half
|
||||
right_half_block.save_state()
|
||||
right_half_block.next_to(SPACE_WIDTH*RIGHT, RIGHT)
|
||||
self.play(right_half_block.restore)
|
||||
self.wait()
|
||||
|
||||
# Show yellow points
|
||||
inspector = DashedLine(
|
||||
ORIGIN, TAU*UP,
|
||||
dashed_segment_length = TAU/24,
|
||||
fill_opacity = 0,
|
||||
stroke_width = 3,
|
||||
stroke_color = WHITE,
|
||||
)
|
||||
inspector.add(*inspector.copy().highlight(BLACK).shift((TAU/24)*UP))
|
||||
inspector.apply_complex_function(np.exp)
|
||||
inspector.scale(0.15)
|
||||
|
||||
inspector_image = inspector.copy()
|
||||
def point_function(point):
|
||||
in_coords = input_plane.point_to_coords(point)
|
||||
out_coords = self.func(in_coords)
|
||||
return output_plane.coords_to_point(*out_coords)
|
||||
|
||||
def update_inspector_image(inspector_image):
|
||||
inspector_image.move_to(point_function(inspector.get_center()))
|
||||
|
||||
inspector_image_update_anim = UpdateFromFunc(
|
||||
inspector_image, update_inspector_image
|
||||
)
|
||||
yellow_points_label = TextMobject("Yellow points")
|
||||
yellow_points_label.scale(0.7)
|
||||
yellow_points_label.highlight(BLACK)
|
||||
|
||||
self.play(
|
||||
inspector.move_to, input_plane.coords_to_point(1.5, 0),
|
||||
inspector.set_stroke, {"width" : 2},
|
||||
)
|
||||
yellow_points_label.next_to(inspector, UP)
|
||||
self.play(
|
||||
Rotating(
|
||||
inspector, about_point = inspector.get_corner(UP+LEFT),
|
||||
rate_func = smooth,
|
||||
run_time = 2,
|
||||
),
|
||||
Write(yellow_points_label)
|
||||
)
|
||||
self.wait()
|
||||
self.play(right_half_block.next_to, SPACE_WIDTH*RIGHT, RIGHT)
|
||||
inspector_image_update_anim.update(0)
|
||||
self.play(ReplacementTransform(
|
||||
inspector.copy(), inspector_image,
|
||||
path_arc = -TAU/4,
|
||||
))
|
||||
self.play(
|
||||
ApplyMethod(
|
||||
inspector.move_to,
|
||||
input_plane.coords_to_point(0, 2),
|
||||
path_arc = -TAU/8,
|
||||
run_time = 3,
|
||||
),
|
||||
inspector_image_update_anim
|
||||
)
|
||||
self.play(
|
||||
ApplyMethod(
|
||||
inspector.move_to,
|
||||
input_plane.coords_to_point(2, 0),
|
||||
path_arc = TAU/4,
|
||||
run_time = 3,
|
||||
),
|
||||
inspector_image_update_anim
|
||||
)
|
||||
self.play(FadeOut(yellow_points_label))
|
||||
|
||||
# Show black zero
|
||||
zeros = tuple(it.starmap(input_plane.coords_to_point, [
|
||||
(-2, -1), (1, 2), (2, -2),
|
||||
]))
|
||||
for x in range(2):
|
||||
for zero in zeros:
|
||||
self.play(
|
||||
ApplyMethod(
|
||||
inspector.move_to, zero,
|
||||
path_arc = -TAU/8,
|
||||
run_time = 2,
|
||||
),
|
||||
inspector_image_update_anim,
|
||||
)
|
||||
self.wait()
|
||||
self.play(FadeOut(VGroup(inspector, inspector_image)))
|
||||
|
||||
# Show all dots and slowly fade them out
|
||||
for dot in dots:
|
||||
dot.scale(1.5)
|
||||
self.play(
|
||||
FadeOut(input_coloring),
|
||||
input_plane.white_parts.highlight, WHITE,
|
||||
LaggedStart(GrowFromCenter, dots)
|
||||
)
|
||||
self.wait()
|
||||
random.shuffle(dots.submobjects)
|
||||
self.play(LaggedStart(
|
||||
FadeOut, dots,
|
||||
lag_ratio = 0.05,
|
||||
run_time = 10,
|
||||
))
|
||||
|
||||
# Ask about whether a region contains a zero
|
||||
question = TextMobject("Does this region \\\\ contain a zero?")
|
||||
question.add_background_rectangle(opacity = 1)
|
||||
question.next_to(input_plane.label, DOWN)
|
||||
square = Square()
|
||||
square.match_background_image_file(input_coloring)
|
||||
square.move_to(input_plane)
|
||||
|
||||
self.play(ShowCreation(square), Write(question))
|
||||
self.wait()
|
||||
quads = [
|
||||
(0, 0.5, 6, 6.25),
|
||||
(1, 1, 0.5, 2),
|
||||
(-1, -1, 3, 4.5),
|
||||
(0, 1.25, 5, 1.7),
|
||||
(-2, -1, 1, 1),
|
||||
]
|
||||
for x, y, width, height in quads:
|
||||
self.play(
|
||||
square.stretch_to_fit_width, width,
|
||||
square.stretch_to_fit_height, height,
|
||||
square.move_to, input_plane.coords_to_point(x, y)
|
||||
)
|
||||
self.wait()
|
||||
|
||||
|
||||
|
||||
###
|
||||
|
||||
def func(self, coord_pair):
|
||||
out_coords = np.array(self.non_renormalized_func(coord_pair))
|
||||
out_norm = np.linalg.norm(out_coords)
|
||||
if out_norm > 0.5:
|
||||
angle = angle_of_vector(out_coords)
|
||||
factor = 0.5-0.1*np.cos(4*angle)
|
||||
target_norm = factor*np.log(out_norm)
|
||||
out_coords *= target_norm / out_norm
|
||||
return tuple(out_coords)
|
||||
|
||||
def get_colorings(self):
|
||||
in_cmos = ColorMappedObjectsScene(
|
||||
func = lambda p : self.non_renormalized_func(
|
||||
(p[0]+self.x_shift, p[1]+self.y_shift)
|
||||
)
|
||||
)
|
||||
scalar = self.output_scalar
|
||||
out_cmos = ColorMappedObjectsScene(
|
||||
func = lambda p : (
|
||||
scalar*(p[0]-self.x_shift), scalar*(p[1]+self.y_shift)
|
||||
)
|
||||
)
|
||||
|
||||
input_coloring = Rectangle(
|
||||
height = self.plane_height,
|
||||
width = self.plane_width,
|
||||
stroke_width = 0,
|
||||
fill_color = WHITE,
|
||||
fill_opacity = 1,
|
||||
)
|
||||
output_coloring = input_coloring.copy()
|
||||
colorings = [input_coloring, output_coloring]
|
||||
vects = [LEFT, RIGHT]
|
||||
cmos_pair = [in_cmos, out_cmos]
|
||||
for coloring, vect, cmos in zip(colorings, vects, cmos_pair):
|
||||
coloring.move_to(self.x_shift*vect + self.y_shift*DOWN)
|
||||
coloring.color_using_background_image(cmos.background_image_file)
|
||||
return colorings
|
||||
|
||||
def get_planes(self):
|
||||
input_plane = NumberPlane(
|
||||
x_radius = self.plane_width/2.0,
|
||||
y_radius = self.plane_height/2.0,
|
||||
)
|
||||
output_plane = input_plane.copy()
|
||||
planes = [input_plane, output_plane]
|
||||
vects = [LEFT, RIGHT]
|
||||
label_texts = ["Input", "Output"]
|
||||
label_colors = [GREEN, RED]
|
||||
for plane, vect, text, color in zip(planes, vects, label_texts, label_colors):
|
||||
plane.stretch_to_fit_width(self.plane_width)
|
||||
plane.add_coordinates(x_vals = range(-2, 3), y_vals = range(-2, 3))
|
||||
plane.white_parts = VGroup(plane.axes, plane.coordinate_labels)
|
||||
plane.lines_to_fade = VGroup(plane.main_lines, plane.secondary_lines)
|
||||
plane.move_to(vect*SPACE_WIDTH/2 + self.y_shift*DOWN)
|
||||
label = TextMobject(text)
|
||||
label.scale(1.5)
|
||||
label.add_background_rectangle()
|
||||
label.move_to(plane)
|
||||
label.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||
plane.add(label)
|
||||
plane.label = label
|
||||
for submob in plane.submobject_family():
|
||||
if isinstance(submob, TexMobject) and hasattr(submob, "background_rectangle"):
|
||||
submob.remove(submob.background_rectangle)
|
||||
|
||||
|
||||
return planes
|
||||
|
||||
def get_dots(self, input_plane, output_plane):
|
||||
step = self.dot_density
|
||||
x_min = -3.0
|
||||
x_max = 3.0
|
||||
y_min = -3.0
|
||||
y_max = 3.0
|
||||
dots = VGroup()
|
||||
for x in np.arange(x_min, x_max + step, step):
|
||||
for y in np.arange(y_max, y_min - step, -step):
|
||||
out_coords = self.func((x, y))
|
||||
dot = Dot(radius = self.dot_radius)
|
||||
dot.set_stroke(BLACK, 1)
|
||||
dot.move_to(input_plane.coords_to_point(x, y))
|
||||
dot.original_position = dot.get_center()
|
||||
dot.generate_target()
|
||||
dot.target.move_to(output_plane.coords_to_point(*out_coords))
|
||||
dot.target_color = rgba_to_color(point_to_rgba(
|
||||
tuple(self.output_scalar*np.array(out_coords))
|
||||
))
|
||||
dots.add(dot)
|
||||
return dots
|
||||
|
||||
class SoWeFoundTheZeros(AltTeacherStudentsScene):
|
||||
def construct(self):
|
||||
self.student_says(
|
||||
"Aha! So we \\\\ found the solutions!",
|
||||
target_mode = "hooray",
|
||||
student_index = 2,
|
||||
bubble_kwargs = {"direction" : LEFT},
|
||||
)
|
||||
self.wait()
|
||||
self.teacher_says(
|
||||
"Er...only \\\\ kind of",
|
||||
target_mode = "hesitant"
|
||||
)
|
||||
self.wait(3)
|
||||
|
||||
class PiCreatureAsksWhatWentWrong(PiCreatureScene):
|
||||
def construct(self):
|
||||
randy = self.pi_creature
|
||||
randy.set_color(YELLOW_E)
|
||||
randy.flip()
|
||||
randy.to_corner(DOWN+LEFT)
|
||||
question = TextMobject("What went wrong?")
|
||||
question.next_to(randy, UP)
|
||||
question.shift_onto_screen()
|
||||
question.save_state()
|
||||
question.shift(DOWN).fade(1)
|
||||
|
||||
self.play(randy.change, "erm")
|
||||
self.wait(2)
|
||||
self.play(
|
||||
Animation(VectorizedPoint(ORIGIN)),
|
||||
question.restore,
|
||||
randy.change, "confused",
|
||||
)
|
||||
self.wait(5)
|
||||
|
||||
|
||||
|
||||
|
|
238
animation/compositions.py
Normal file
238
animation/compositions.py
Normal file
|
@ -0,0 +1,238 @@
|
|||
import numpy as np
|
||||
import itertools as it
|
||||
|
||||
from helpers import *
|
||||
|
||||
import warnings
|
||||
from mobject import Mobject, Group
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from animation import Animation
|
||||
from transform import Transform
|
||||
|
||||
class LaggedStart(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 2,
|
||||
"lag_ratio" : 0.5,
|
||||
}
|
||||
def __init__(self, AnimationClass, mobject, arg_creator = None, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
for key in "rate_func", "run_time", "lag_ratio":
|
||||
if key in kwargs:
|
||||
kwargs.pop(key)
|
||||
if arg_creator is None:
|
||||
arg_creator = lambda mobject : (mobject,)
|
||||
self.subanimations = [
|
||||
AnimationClass(
|
||||
*arg_creator(submob),
|
||||
run_time = self.run_time,
|
||||
rate_func = squish_rate_func(
|
||||
self.rate_func, beta, beta + self.lag_ratio
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
for submob, beta in zip(
|
||||
mobject,
|
||||
np.linspace(0, 1-self.lag_ratio, len(mobject))
|
||||
)
|
||||
]
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update(self, alpha):
|
||||
for anim in self.subanimations:
|
||||
anim.update(alpha)
|
||||
return self
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
for anim in self.subanimations:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
class Succession(Animation):
|
||||
CONFIG = {
|
||||
"rate_func" : None,
|
||||
}
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Each arg will either be an animation, or an animation class
|
||||
followed by its arguments (and potentially a dict for
|
||||
configuration).
|
||||
For example,
|
||||
Succession(
|
||||
ShowCreation(circle),
|
||||
Transform, circle, square,
|
||||
Transform, circle, triangle,
|
||||
ApplyMethod, circle.shift, 2*UP, {"run_time" : 2},
|
||||
)
|
||||
"""
|
||||
animations = []
|
||||
state = {
|
||||
"animations" : animations,
|
||||
"curr_class" : None,
|
||||
"curr_class_args" : [],
|
||||
"curr_class_config" : {},
|
||||
}
|
||||
def invoke_curr_class(state):
|
||||
if state["curr_class"] is None:
|
||||
return
|
||||
anim = state["curr_class"](
|
||||
*state["curr_class_args"],
|
||||
**state["curr_class_config"]
|
||||
)
|
||||
state["animations"].append(anim)
|
||||
anim.update(1)
|
||||
state["curr_class"] = None
|
||||
state["curr_class_args"] = []
|
||||
state["curr_class_config"] = {}
|
||||
|
||||
for arg in args:
|
||||
if isinstance(arg, Animation):
|
||||
animations.append(arg)
|
||||
arg.update(1)
|
||||
invoke_curr_class(state)
|
||||
elif isinstance(arg, type) and issubclass(arg, Animation):
|
||||
invoke_curr_class(state)
|
||||
state["curr_class"] = arg
|
||||
elif isinstance(arg, dict):
|
||||
state["curr_class_config"] = arg
|
||||
else:
|
||||
state["curr_class_args"].append(arg)
|
||||
invoke_curr_class(state)
|
||||
for anim in animations:
|
||||
anim.update(0)
|
||||
|
||||
animations = filter (lambda x : not(x.empty), animations)
|
||||
|
||||
self.run_times = [anim.run_time for anim in animations]
|
||||
if "run_time" in kwargs:
|
||||
run_time = kwargs.pop("run_time")
|
||||
warnings.warn("Succession doesn't currently support explicit run_time.")
|
||||
run_time = sum(self.run_times)
|
||||
self.num_anims = len(animations)
|
||||
if self.num_anims == 0:
|
||||
self.empty = True
|
||||
self.animations = animations
|
||||
#Have to keep track of this run_time, because Scene.play
|
||||
#might very well mess with it.
|
||||
self.original_run_time = run_time
|
||||
|
||||
# critical_alphas[i] is the start alpha of self.animations[i]
|
||||
# critical_alphas[i + 1] is the end alpha of self.animations[i]
|
||||
critical_times = np.concatenate(([0], np.cumsum(self.run_times)))
|
||||
self.critical_alphas = map (lambda x : np.true_divide(x, run_time), critical_times) if self.num_anims > 0 else [0.0]
|
||||
|
||||
# self.scene_mobjects_at_time[i] is the scene's mobjects at start of self.animations[i]
|
||||
# self.scene_mobjects_at_time[i + 1] is the scene mobjects at end of self.animations[i]
|
||||
self.scene_mobjects_at_time = [None for i in range(self.num_anims + 1)]
|
||||
self.scene_mobjects_at_time[0] = Group()
|
||||
for i in range(self.num_anims):
|
||||
self.scene_mobjects_at_time[i + 1] = self.scene_mobjects_at_time[i].copy()
|
||||
self.animations[i].clean_up(self.scene_mobjects_at_time[i + 1])
|
||||
|
||||
self.current_alpha = 0
|
||||
self.current_anim_index = 0 # If self.num_anims == 0, this is an invalid index, but so it goes
|
||||
if self.num_anims > 0:
|
||||
self.mobject = self.scene_mobjects_at_time[0]
|
||||
self.mobject.add(self.animations[0].mobject)
|
||||
else:
|
||||
self.mobject = Group()
|
||||
|
||||
Animation.__init__(self, self.mobject, run_time = run_time, **kwargs)
|
||||
|
||||
# Beware: This does NOT take care of calling update(0) on the subanimation.
|
||||
# This was important to avoid a pernicious possibility in which subanimations were called
|
||||
# with update twice, which could in turn call a sub-Succession with update four times,
|
||||
# continuing exponentially.
|
||||
def jump_to_start_of_anim(self, index):
|
||||
if index != self.current_anim_index:
|
||||
self.mobject.remove(*self.mobject.submobjects) # Should probably have a cleaner "remove_all" method...
|
||||
self.mobject.add(*self.scene_mobjects_at_time[index].submobjects)
|
||||
self.mobject.add(self.animations[index].mobject)
|
||||
|
||||
for i in range(index):
|
||||
self.animations[i].update(1)
|
||||
|
||||
self.current_anim_index = index
|
||||
self.current_alpha = self.critical_alphas[index]
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
if self.num_anims == 0:
|
||||
# This probably doesn't matter for anything, but just in case,
|
||||
# we want it in the future, we set current_alpha even in this case
|
||||
self.current_alpha = alpha
|
||||
return
|
||||
|
||||
gt_alpha_iter = it.ifilter(
|
||||
lambda i : self.critical_alphas[i+1] >= alpha,
|
||||
range(self.num_anims)
|
||||
)
|
||||
i = next(gt_alpha_iter, None)
|
||||
if i == None:
|
||||
# In this case, we assume what is happening is that alpha is 1.0,
|
||||
# but that rounding error is causing us to overshoot the end of
|
||||
# self.critical_alphas (which is also 1.0)
|
||||
if not abs(alpha - 1) < 0.001:
|
||||
warnings.warn(
|
||||
"Rounding error not near alpha=1 in Succession.update_mobject," + \
|
||||
"instead alpha = %f"%alpha
|
||||
)
|
||||
print self.critical_alphas, alpha
|
||||
i = self.num_anims - 1
|
||||
|
||||
# At this point, we should have self.critical_alphas[i] <= alpha <= self.critical_alphas[i +1]
|
||||
|
||||
self.jump_to_start_of_anim(i)
|
||||
sub_alpha = inverse_interpolate(
|
||||
self.critical_alphas[i],
|
||||
self.critical_alphas[i + 1],
|
||||
alpha
|
||||
)
|
||||
self.animations[i].update(sub_alpha)
|
||||
self.current_alpha = alpha
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
# We clean up as though we've played ALL animations, even if
|
||||
# clean_up is called in middle of things
|
||||
for anim in self.animations:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
class AnimationGroup(Animation):
|
||||
CONFIG = {
|
||||
"rate_func" : None
|
||||
}
|
||||
def __init__(self, *sub_anims, **kwargs):
|
||||
sub_anims = filter (lambda x : not(x.empty), sub_anims)
|
||||
digest_config(self, locals())
|
||||
self.update_config(**kwargs) # Handles propagation to self.sub_anims
|
||||
|
||||
if len(sub_anims) == 0:
|
||||
self.empty = True
|
||||
self.run_time = 0
|
||||
else:
|
||||
self.run_time = max([a.run_time for a in sub_anims])
|
||||
everything = Mobject(*[a.mobject for a in sub_anims])
|
||||
Animation.__init__(self, everything, **kwargs)
|
||||
|
||||
def update(self, alpha):
|
||||
for anim in self.sub_anims:
|
||||
anim.update(alpha * self.run_time / anim.run_time)
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
for anim in self.sub_anims:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
def update_config(self, **kwargs):
|
||||
Animation.update_config(self, **kwargs)
|
||||
|
||||
# If AnimationGroup is called with any configuration,
|
||||
# it is propagated to the sub_animations
|
||||
for anim in self.sub_anims:
|
||||
anim.update_config(**kwargs)
|
||||
|
||||
class EmptyAnimation(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 0,
|
||||
"empty" : True
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
return Animation.__init__(self, Group(), *args, **kwargs)
|
|
@ -288,8 +288,6 @@ class WiggleOutThenIn(Animation):
|
|||
about_point = self.rotate_about_point
|
||||
)
|
||||
|
||||
### Animation modifiers ###
|
||||
|
||||
class ApplyToCenters(Animation):
|
||||
def __init__(self, AnimationClass, mobjects, **kwargs):
|
||||
full_kwargs = AnimationClass.CONFIG
|
||||
|
@ -312,229 +310,3 @@ class ApplyToCenters(Animation):
|
|||
center_mob.get_center()-mobject.get_center()
|
||||
)
|
||||
|
||||
class LaggedStart(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 2,
|
||||
"lag_ratio" : 0.5,
|
||||
}
|
||||
def __init__(self, AnimationClass, mobject, arg_creator = None, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
for key in "rate_func", "run_time", "lag_ratio":
|
||||
if key in kwargs:
|
||||
kwargs.pop(key)
|
||||
if arg_creator is None:
|
||||
arg_creator = lambda mobject : (mobject,)
|
||||
self.subanimations = [
|
||||
AnimationClass(
|
||||
*arg_creator(submob),
|
||||
run_time = self.run_time,
|
||||
rate_func = squish_rate_func(
|
||||
self.rate_func, beta, beta + self.lag_ratio
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
for submob, beta in zip(
|
||||
mobject,
|
||||
np.linspace(0, 1-self.lag_ratio, len(mobject))
|
||||
)
|
||||
]
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update(self, alpha):
|
||||
for anim in self.subanimations:
|
||||
anim.update(alpha)
|
||||
return self
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
for anim in self.subanimations:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
class Succession(Animation):
|
||||
CONFIG = {
|
||||
"rate_func" : None,
|
||||
}
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Each arg will either be an animation, or an animation class
|
||||
followed by its arguments (and potentially a dict for
|
||||
configuration).
|
||||
For example,
|
||||
Succession(
|
||||
ShowCreation(circle),
|
||||
Transform, circle, square,
|
||||
Transform, circle, triangle,
|
||||
ApplyMethod, circle.shift, 2*UP, {"run_time" : 2},
|
||||
)
|
||||
"""
|
||||
animations = []
|
||||
state = {
|
||||
"animations" : animations,
|
||||
"curr_class" : None,
|
||||
"curr_class_args" : [],
|
||||
"curr_class_config" : {},
|
||||
}
|
||||
def invoke_curr_class(state):
|
||||
if state["curr_class"] is None:
|
||||
return
|
||||
anim = state["curr_class"](
|
||||
*state["curr_class_args"],
|
||||
**state["curr_class_config"]
|
||||
)
|
||||
state["animations"].append(anim)
|
||||
anim.update(1)
|
||||
state["curr_class"] = None
|
||||
state["curr_class_args"] = []
|
||||
state["curr_class_config"] = {}
|
||||
|
||||
for arg in args:
|
||||
if isinstance(arg, Animation):
|
||||
animations.append(arg)
|
||||
arg.update(1)
|
||||
invoke_curr_class(state)
|
||||
elif isinstance(arg, type) and issubclass(arg, Animation):
|
||||
invoke_curr_class(state)
|
||||
state["curr_class"] = arg
|
||||
elif isinstance(arg, dict):
|
||||
state["curr_class_config"] = arg
|
||||
else:
|
||||
state["curr_class_args"].append(arg)
|
||||
invoke_curr_class(state)
|
||||
for anim in animations:
|
||||
anim.update(0)
|
||||
|
||||
animations = filter (lambda x : not(x.empty), animations)
|
||||
|
||||
self.run_times = [anim.run_time for anim in animations]
|
||||
if "run_time" in kwargs:
|
||||
run_time = kwargs.pop("run_time")
|
||||
warnings.warn("Succession doesn't currently support explicit run_time.")
|
||||
run_time = sum(self.run_times)
|
||||
self.num_anims = len(animations)
|
||||
if self.num_anims == 0:
|
||||
self.empty = True
|
||||
self.animations = animations
|
||||
#Have to keep track of this run_time, because Scene.play
|
||||
#might very well mess with it.
|
||||
self.original_run_time = run_time
|
||||
|
||||
# critical_alphas[i] is the start alpha of self.animations[i]
|
||||
# critical_alphas[i + 1] is the end alpha of self.animations[i]
|
||||
critical_times = np.concatenate(([0], np.cumsum(self.run_times)))
|
||||
self.critical_alphas = map (lambda x : np.true_divide(x, run_time), critical_times) if self.num_anims > 0 else [0.0]
|
||||
|
||||
# self.scene_mobjects_at_time[i] is the scene's mobjects at start of self.animations[i]
|
||||
# self.scene_mobjects_at_time[i + 1] is the scene mobjects at end of self.animations[i]
|
||||
self.scene_mobjects_at_time = [None for i in range(self.num_anims + 1)]
|
||||
self.scene_mobjects_at_time[0] = Group()
|
||||
for i in range(self.num_anims):
|
||||
self.scene_mobjects_at_time[i + 1] = self.scene_mobjects_at_time[i].copy()
|
||||
self.animations[i].clean_up(self.scene_mobjects_at_time[i + 1])
|
||||
|
||||
self.current_alpha = 0
|
||||
self.current_anim_index = 0 # If self.num_anims == 0, this is an invalid index, but so it goes
|
||||
if self.num_anims > 0:
|
||||
self.mobject = self.scene_mobjects_at_time[0]
|
||||
self.mobject.add(self.animations[0].mobject)
|
||||
else:
|
||||
self.mobject = Group()
|
||||
|
||||
Animation.__init__(self, self.mobject, run_time = run_time, **kwargs)
|
||||
|
||||
# Beware: This does NOT take care of calling update(0) on the subanimation.
|
||||
# This was important to avoid a pernicious possibility in which subanimations were called
|
||||
# with update twice, which could in turn call a sub-Succession with update four times,
|
||||
# continuing exponentially.
|
||||
def jump_to_start_of_anim(self, index):
|
||||
if index != self.current_anim_index:
|
||||
self.mobject.remove(*self.mobject.submobjects) # Should probably have a cleaner "remove_all" method...
|
||||
self.mobject.add(*self.scene_mobjects_at_time[index].submobjects)
|
||||
self.mobject.add(self.animations[index].mobject)
|
||||
|
||||
for i in range(index):
|
||||
self.animations[i].update(1)
|
||||
|
||||
self.current_anim_index = index
|
||||
self.current_alpha = self.critical_alphas[index]
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
if self.num_anims == 0:
|
||||
# This probably doesn't matter for anything, but just in case,
|
||||
# we want it in the future, we set current_alpha even in this case
|
||||
self.current_alpha = alpha
|
||||
return
|
||||
|
||||
gt_alpha_iter = it.ifilter(
|
||||
lambda i : self.critical_alphas[i+1] >= alpha,
|
||||
range(self.num_anims)
|
||||
)
|
||||
i = next(gt_alpha_iter, None)
|
||||
if i == None:
|
||||
# In this case, we assume what is happening is that alpha is 1.0,
|
||||
# but that rounding error is causing us to overshoot the end of
|
||||
# self.critical_alphas (which is also 1.0)
|
||||
if not abs(alpha - 1) < 0.001:
|
||||
warnings.warn(
|
||||
"Rounding error not near alpha=1 in Succession.update_mobject," + \
|
||||
"instead alpha = %f"%alpha
|
||||
)
|
||||
print self.critical_alphas, alpha
|
||||
i = self.num_anims - 1
|
||||
|
||||
# At this point, we should have self.critical_alphas[i] <= alpha <= self.critical_alphas[i +1]
|
||||
|
||||
self.jump_to_start_of_anim(i)
|
||||
sub_alpha = inverse_interpolate(
|
||||
self.critical_alphas[i],
|
||||
self.critical_alphas[i + 1],
|
||||
alpha
|
||||
)
|
||||
self.animations[i].update(sub_alpha)
|
||||
self.current_alpha = alpha
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
# We clean up as though we've played ALL animations, even if
|
||||
# clean_up is called in middle of things
|
||||
for anim in self.animations:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
class AnimationGroup(Animation):
|
||||
CONFIG = {
|
||||
"rate_func" : None
|
||||
}
|
||||
def __init__(self, *sub_anims, **kwargs):
|
||||
sub_anims = filter (lambda x : not(x.empty), sub_anims)
|
||||
digest_config(self, locals())
|
||||
self.update_config(**kwargs) # Handles propagation to self.sub_anims
|
||||
|
||||
if len(sub_anims) == 0:
|
||||
self.empty = True
|
||||
self.run_time = 0
|
||||
else:
|
||||
self.run_time = max([a.run_time for a in sub_anims])
|
||||
everything = Mobject(*[a.mobject for a in sub_anims])
|
||||
Animation.__init__(self, everything, **kwargs)
|
||||
|
||||
def update(self, alpha):
|
||||
for anim in self.sub_anims:
|
||||
anim.update(alpha * self.run_time / anim.run_time)
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
for anim in self.sub_anims:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
def update_config(self, **kwargs):
|
||||
Animation.update_config(self, **kwargs)
|
||||
|
||||
# If AnimationGroup is called with any configuration,
|
||||
# it is propagated to the sub_animations
|
||||
for anim in self.sub_anims:
|
||||
anim.update_config(**kwargs)
|
||||
|
||||
class EmptyAnimation(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 0,
|
||||
"empty" : True
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
return Animation.__init__(self, Group(), *args, **kwargs)
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -15,6 +15,7 @@ from camera import Camera
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -165,6 +165,10 @@ class VMobject(Mobject):
|
|||
def get_background_image_file(self):
|
||||
return self.background_image_file
|
||||
|
||||
def match_background_image_file(self, vmobject):
|
||||
self.color_using_background_image(vmobject.get_background_image_file())
|
||||
return self
|
||||
|
||||
## Drawing
|
||||
def start_at(self, point):
|
||||
if len(self.points) == 0:
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -10,6 +10,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
|
||||
from animation.playground import *
|
||||
|
|
|
@ -11,6 +11,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
|
||||
from animation.playground import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -11,7 +11,8 @@ from topics.three_dimensions import Stars
|
|||
|
||||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import TurnInsideOut, Vibrate
|
||||
from topics.geometry import *
|
||||
from topics.characters import Randolph, Mathematician
|
||||
|
|
|
@ -12,6 +12,7 @@ from topics.three_dimensions import Stars
|
|||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import Randolph
|
||||
from topics.functions import *
|
||||
|
|
|
@ -12,6 +12,7 @@ from topics.three_dimensions import Stars
|
|||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import TurnInsideOut, Vibrate
|
||||
from topics.geometry import *
|
||||
from topics.characters import Randolph, Mathematician
|
||||
|
|
|
@ -12,6 +12,7 @@ from topics.three_dimensions import Stars
|
|||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import TurnInsideOut, Vibrate
|
||||
from topics.geometry import *
|
||||
from topics.characters import Randolph, Mathematician
|
||||
|
|
|
@ -11,6 +11,7 @@ from topics.three_dimensions import Stars
|
|||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import TurnInsideOut, Vibrate
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -12,6 +12,7 @@ from topics.three_dimensions import Stars
|
|||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import Randolph
|
||||
from topics.functions import *
|
||||
|
|
|
@ -13,6 +13,7 @@ from topics.three_dimensions import Stars
|
|||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import TurnInsideOut, Vibrate
|
||||
from topics.geometry import *
|
||||
from topics.characters import Randolph, Mathematician
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -11,6 +11,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -10,6 +10,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -10,6 +10,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -9,6 +9,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -10,6 +10,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -10,6 +10,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject.vectorized_mobject import VMobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
|
|
|
@ -5,6 +5,7 @@ import scipy
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -9,6 +9,7 @@ from mobject.point_cloud_mobject import Mobject1D
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -11,6 +11,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -13,6 +13,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -12,6 +12,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -15,6 +15,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -11,6 +11,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject import Mobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -6,6 +6,7 @@ from mobject import Mobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject import Mobject
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -9,6 +9,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -6,6 +6,7 @@ import scipy
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,6 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -10,7 +10,8 @@ from topics.geometry import ScreenRectangle
|
|||
|
||||
from animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import Write, ShowCreation, AnimationGroup
|
||||
from animation.simple_animations import Write, ShowCreation
|
||||
from animation.compositions import AnimationGroup
|
||||
from scene import Scene
|
||||
|
||||
|
||||
|
@ -389,25 +390,28 @@ class PiCreatureScene(Scene):
|
|||
"total_wait_time" : 0,
|
||||
"seconds_to_blink" : 3,
|
||||
"pi_creatures_start_on_screen" : True,
|
||||
"default_pi_creature_kwargs" : {},
|
||||
"default_pi_creature_class" : Mortimer,
|
||||
"default_pi_creature_kwargs" : {
|
||||
"color" : GREY_BROWN,
|
||||
"flip_at_start" : True,
|
||||
},
|
||||
"default_pi_creature_start_corner" : DOWN+LEFT,
|
||||
}
|
||||
def setup(self):
|
||||
self.pi_creatures = VGroup(
|
||||
*self.create_pi_creatures(**self.default_pi_creature_kwargs)
|
||||
)
|
||||
self.pi_creatures = self.create_pi_creatures()
|
||||
self.pi_creature = self.get_primary_pi_creature()
|
||||
if self.pi_creatures_start_on_screen:
|
||||
self.add(*self.pi_creatures)
|
||||
|
||||
def create_pi_creatures(self):
|
||||
"""
|
||||
Likely updated for subclasses
|
||||
Likely updated for subclasses
|
||||
"""
|
||||
return VGroup(self.create_pi_creature(**self.default_pi_creature_kwargs))
|
||||
return VGroup(self.create_pi_creature())
|
||||
|
||||
def create_pi_creature(self):
|
||||
return self.default_pi_creature_class(**self.default_pi_creature_kwargs).to_corner(DOWN+RIGHT)
|
||||
pi_creature = PiCreature(**self.default_pi_creature_kwargs)
|
||||
pi_creature.to_corner(self.default_pi_creature_start_corner)
|
||||
return pi_creature
|
||||
|
||||
def get_pi_creatures(self):
|
||||
return self.pi_creatures
|
||||
|
|
|
@ -7,6 +7,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
|
||||
from animation.playground import *
|
||||
|
|
|
@ -6,7 +6,8 @@ from mobject.svg_mobject import SVGMobject
|
|||
from mobject.tex_mobject import TextMobject, TexMobject, Brace
|
||||
|
||||
from animation import Animation
|
||||
from animation.simple_animations import Rotating, LaggedStart, AnimationGroup
|
||||
from animation.simple_animations import Rotating
|
||||
from animation.compositions import LaggedStart, AnimationGroup
|
||||
from animation.transform import ApplyMethod, FadeIn, GrowFromCenter
|
||||
|
||||
from topics.geometry import Circle, Line, Rectangle, Square, \
|
||||
|
|
Loading…
Add table
Reference in a new issue