diff --git a/active_projects/WindingNumber.py b/active_projects/WindingNumber.py index 38b573e8..7f070458 100644 --- a/active_projects/WindingNumber.py +++ b/active_projects/WindingNumber.py @@ -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 * diff --git a/active_projects/WindingNumber_G.py b/active_projects/WindingNumber_G.py index 2caf0a84..2b5a3934 100644 --- a/active_projects/WindingNumber_G.py +++ b/active_projects/WindingNumber_G.py @@ -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) diff --git a/animation/compositions.py b/animation/compositions.py new file mode 100644 index 00000000..2b555a43 --- /dev/null +++ b/animation/compositions.py @@ -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) diff --git a/animation/simple_animations.py b/animation/simple_animations.py index f035353a..b26edd43 100644 --- a/animation/simple_animations.py +++ b/animation/simple_animations.py @@ -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) diff --git a/eop/bayes.py b/eop/bayes.py index b916f2b6..3eb0469e 100644 --- a/eop/bayes.py +++ b/eop/bayes.py @@ -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 * diff --git a/eop/bayes_footnote.py b/eop/bayes_footnote.py index dd978212..f212be30 100644 --- a/eop/bayes_footnote.py +++ b/eop/bayes_footnote.py @@ -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 * diff --git a/eop/combinations.py b/eop/combinations.py index 85891823..701f19e5 100644 --- a/eop/combinations.py +++ b/eop/combinations.py @@ -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 * diff --git a/eop/independence.py b/eop/independence.py index eaabbdef..0cc28aec 100644 --- a/eop/independence.py +++ b/eop/independence.py @@ -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 * diff --git a/example_scenes.py b/example_scenes.py index d9538204..b0ffb4b0 100644 --- a/example_scenes.py +++ b/example_scenes.py @@ -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 * diff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.py index ef482bbd..603a2867 100644 --- a/mobject/vectorized_mobject.py +++ b/mobject/vectorized_mobject.py @@ -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: diff --git a/old_projects/256.py b/old_projects/256.py index 2ba199cf..3e13551b 100644 --- a/old_projects/256.py +++ b/old_projects/256.py @@ -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 * diff --git a/old_projects/basel/basel.py b/old_projects/basel/basel.py index 20814be5..ece1b189 100644 --- a/old_projects/basel/basel.py +++ b/old_projects/basel/basel.py @@ -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 * diff --git a/old_projects/basel/basel2.py b/old_projects/basel/basel2.py index dd3049a9..f940c8c6 100644 --- a/old_projects/basel/basel2.py +++ b/old_projects/basel/basel2.py @@ -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 * diff --git a/old_projects/bell.py b/old_projects/bell.py index 5ab94e62..14f5b035 100644 --- a/old_projects/bell.py +++ b/old_projects/bell.py @@ -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 * diff --git a/old_projects/borsuk.py b/old_projects/borsuk.py index 218cb38d..25d6f750 100644 --- a/old_projects/borsuk.py +++ b/old_projects/borsuk.py @@ -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 * diff --git a/old_projects/brachistochrone/curves.py b/old_projects/brachistochrone/curves.py index d51f4d74..7f703727 100644 --- a/old_projects/brachistochrone/curves.py +++ b/old_projects/brachistochrone/curves.py @@ -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 diff --git a/old_projects/brachistochrone/cycloid.py b/old_projects/brachistochrone/cycloid.py index 695a1c0d..0a51b320 100644 --- a/old_projects/brachistochrone/cycloid.py +++ b/old_projects/brachistochrone/cycloid.py @@ -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 * diff --git a/old_projects/brachistochrone/graveyard.py b/old_projects/brachistochrone/graveyard.py index 1e73d6ef..430670c2 100644 --- a/old_projects/brachistochrone/graveyard.py +++ b/old_projects/brachistochrone/graveyard.py @@ -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 diff --git a/old_projects/brachistochrone/light.py b/old_projects/brachistochrone/light.py index 2ebc4545..8b179ddb 100644 --- a/old_projects/brachistochrone/light.py +++ b/old_projects/brachistochrone/light.py @@ -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 diff --git a/old_projects/brachistochrone/misc.py b/old_projects/brachistochrone/misc.py index d3a2050f..9e21a609 100644 --- a/old_projects/brachistochrone/misc.py +++ b/old_projects/brachistochrone/misc.py @@ -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 * diff --git a/old_projects/brachistochrone/multilayered.py b/old_projects/brachistochrone/multilayered.py index 29075d30..49fcb15c 100644 --- a/old_projects/brachistochrone/multilayered.py +++ b/old_projects/brachistochrone/multilayered.py @@ -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 * diff --git a/old_projects/brachistochrone/wordplay.py b/old_projects/brachistochrone/wordplay.py index cff199da..4b4eabce 100644 --- a/old_projects/brachistochrone/wordplay.py +++ b/old_projects/brachistochrone/wordplay.py @@ -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 diff --git a/old_projects/crypto.py b/old_projects/crypto.py index be3b5f0a..a53a1dfd 100644 --- a/old_projects/crypto.py +++ b/old_projects/crypto.py @@ -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 * diff --git a/old_projects/domino_play.py b/old_projects/domino_play.py index d9402c6a..3090f907 100644 --- a/old_projects/domino_play.py +++ b/old_projects/domino_play.py @@ -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 * diff --git a/old_projects/efvgt.py b/old_projects/efvgt.py index 2e431343..bc57cd9f 100644 --- a/old_projects/efvgt.py +++ b/old_projects/efvgt.py @@ -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 * diff --git a/old_projects/eoc/chapter1.py b/old_projects/eoc/chapter1.py index 900d82ed..13dfe4a4 100644 --- a/old_projects/eoc/chapter1.py +++ b/old_projects/eoc/chapter1.py @@ -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 * diff --git a/old_projects/eoc/chapter10.py b/old_projects/eoc/chapter10.py index eaa12d79..d412d11a 100644 --- a/old_projects/eoc/chapter10.py +++ b/old_projects/eoc/chapter10.py @@ -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 * diff --git a/old_projects/eoc/chapter2.py b/old_projects/eoc/chapter2.py index 385a3d56..29236d7f 100644 --- a/old_projects/eoc/chapter2.py +++ b/old_projects/eoc/chapter2.py @@ -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 * diff --git a/old_projects/eoc/chapter3.py b/old_projects/eoc/chapter3.py index 038d557c..117359a0 100644 --- a/old_projects/eoc/chapter3.py +++ b/old_projects/eoc/chapter3.py @@ -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 * diff --git a/old_projects/eoc/chapter4.py b/old_projects/eoc/chapter4.py index 52453904..ca61f797 100644 --- a/old_projects/eoc/chapter4.py +++ b/old_projects/eoc/chapter4.py @@ -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 * diff --git a/old_projects/eoc/chapter5.py b/old_projects/eoc/chapter5.py index 05c98beb..5f02ade3 100644 --- a/old_projects/eoc/chapter5.py +++ b/old_projects/eoc/chapter5.py @@ -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 * diff --git a/old_projects/eoc/chapter6.py b/old_projects/eoc/chapter6.py index c9fe9e73..5d32c7e1 100644 --- a/old_projects/eoc/chapter6.py +++ b/old_projects/eoc/chapter6.py @@ -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 * diff --git a/old_projects/eoc/chapter7.py b/old_projects/eoc/chapter7.py index b10df5f5..eb4b017a 100644 --- a/old_projects/eoc/chapter7.py +++ b/old_projects/eoc/chapter7.py @@ -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 * diff --git a/old_projects/eoc/chapter8.py b/old_projects/eoc/chapter8.py index 00b75026..7f420e8d 100644 --- a/old_projects/eoc/chapter8.py +++ b/old_projects/eoc/chapter8.py @@ -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 * diff --git a/old_projects/eoc/chapter9.py b/old_projects/eoc/chapter9.py index a8f860b6..57eb9f80 100644 --- a/old_projects/eoc/chapter9.py +++ b/old_projects/eoc/chapter9.py @@ -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 * diff --git a/old_projects/eoc/footnote.py b/old_projects/eoc/footnote.py index 0eca1562..38b2da94 100644 --- a/old_projects/eoc/footnote.py +++ b/old_projects/eoc/footnote.py @@ -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 * diff --git a/old_projects/eoc/old_chapter1.py b/old_projects/eoc/old_chapter1.py index da371ad4..38d642f5 100644 --- a/old_projects/eoc/old_chapter1.py +++ b/old_projects/eoc/old_chapter1.py @@ -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 * diff --git a/old_projects/eola/chapter0.py b/old_projects/eola/chapter0.py index eb1315dd..be09e132 100644 --- a/old_projects/eola/chapter0.py +++ b/old_projects/eola/chapter0.py @@ -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 * diff --git a/old_projects/eola/chapter1.py b/old_projects/eola/chapter1.py index e4e4616e..6dd2abf9 100644 --- a/old_projects/eola/chapter1.py +++ b/old_projects/eola/chapter1.py @@ -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 * diff --git a/old_projects/eola/chapter10.py b/old_projects/eola/chapter10.py index 2fde6a8b..b1c65eb2 100644 --- a/old_projects/eola/chapter10.py +++ b/old_projects/eola/chapter10.py @@ -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 * diff --git a/old_projects/eola/chapter11.py b/old_projects/eola/chapter11.py index f3ca6cbe..a38e682f 100644 --- a/old_projects/eola/chapter11.py +++ b/old_projects/eola/chapter11.py @@ -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 * diff --git a/old_projects/eola/chapter2.py b/old_projects/eola/chapter2.py index 93ec2130..8a4575d4 100644 --- a/old_projects/eola/chapter2.py +++ b/old_projects/eola/chapter2.py @@ -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 * diff --git a/old_projects/eola/chapter3.py b/old_projects/eola/chapter3.py index afd1fae5..345cd83a 100644 --- a/old_projects/eola/chapter3.py +++ b/old_projects/eola/chapter3.py @@ -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 * diff --git a/old_projects/eola/chapter4.py b/old_projects/eola/chapter4.py index b29fb1f0..a31da52e 100644 --- a/old_projects/eola/chapter4.py +++ b/old_projects/eola/chapter4.py @@ -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 * diff --git a/old_projects/eola/chapter5.py b/old_projects/eola/chapter5.py index 7e3afa8a..f5039b21 100644 --- a/old_projects/eola/chapter5.py +++ b/old_projects/eola/chapter5.py @@ -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 * diff --git a/old_projects/eola/chapter6.py b/old_projects/eola/chapter6.py index 5a442e69..ba1d6bf0 100644 --- a/old_projects/eola/chapter6.py +++ b/old_projects/eola/chapter6.py @@ -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 * diff --git a/old_projects/eola/chapter7.py b/old_projects/eola/chapter7.py index 3cd2e1c1..65793e7d 100644 --- a/old_projects/eola/chapter7.py +++ b/old_projects/eola/chapter7.py @@ -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 * diff --git a/old_projects/eola/chapter8.py b/old_projects/eola/chapter8.py index 4d90daec..fbd050e4 100644 --- a/old_projects/eola/chapter8.py +++ b/old_projects/eola/chapter8.py @@ -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 * diff --git a/old_projects/eola/chapter8p2.py b/old_projects/eola/chapter8p2.py index 77a3489d..03a01d05 100644 --- a/old_projects/eola/chapter8p2.py +++ b/old_projects/eola/chapter8p2.py @@ -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 * diff --git a/old_projects/eola/chapter9.py b/old_projects/eola/chapter9.py index c75e21e9..4f655f41 100644 --- a/old_projects/eola/chapter9.py +++ b/old_projects/eola/chapter9.py @@ -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 * diff --git a/old_projects/eola/footnote.py b/old_projects/eola/footnote.py index 58675c9e..86306685 100644 --- a/old_projects/eola/footnote.py +++ b/old_projects/eola/footnote.py @@ -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 * diff --git a/old_projects/eola/footnote2.py b/old_projects/eola/footnote2.py index 10580f08..c67e5e9e 100644 --- a/old_projects/eola/footnote2.py +++ b/old_projects/eola/footnote2.py @@ -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 * diff --git a/old_projects/eola/thumbnails.py b/old_projects/eola/thumbnails.py index ae5de87a..1fda50fe 100644 --- a/old_projects/eola/thumbnails.py +++ b/old_projects/eola/thumbnails.py @@ -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 * diff --git a/old_projects/fourier.py b/old_projects/fourier.py index c725d148..3f9523ae 100644 --- a/old_projects/fourier.py +++ b/old_projects/fourier.py @@ -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 * diff --git a/old_projects/fractal_charm.py b/old_projects/fractal_charm.py index 7b759332..11b8812e 100644 --- a/old_projects/fractal_charm.py +++ b/old_projects/fractal_charm.py @@ -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 * diff --git a/old_projects/fractal_dimension.py b/old_projects/fractal_dimension.py index 1ec5520c..f1a24641 100644 --- a/old_projects/fractal_dimension.py +++ b/old_projects/fractal_dimension.py @@ -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 * diff --git a/old_projects/hanoi.py b/old_projects/hanoi.py index daebf3b9..236ddcfb 100644 --- a/old_projects/hanoi.py +++ b/old_projects/hanoi.py @@ -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 * diff --git a/old_projects/highD.py b/old_projects/highD.py index d264876f..df34c46b 100644 --- a/old_projects/highD.py +++ b/old_projects/highD.py @@ -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 * diff --git a/old_projects/leibniz.py b/old_projects/leibniz.py index c551d247..714f1fa6 100644 --- a/old_projects/leibniz.py +++ b/old_projects/leibniz.py @@ -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 * diff --git a/old_projects/mug.py b/old_projects/mug.py index 2ba68d08..f58c6a6f 100644 --- a/old_projects/mug.py +++ b/old_projects/mug.py @@ -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 * diff --git a/old_projects/nn/part1.py b/old_projects/nn/part1.py index 91b8884b..141d54af 100644 --- a/old_projects/nn/part1.py +++ b/old_projects/nn/part1.py @@ -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 * diff --git a/old_projects/nn/part2.py b/old_projects/nn/part2.py index bde9e1ad..60d03390 100644 --- a/old_projects/nn/part2.py +++ b/old_projects/nn/part2.py @@ -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 * diff --git a/old_projects/nn/playground.py b/old_projects/nn/playground.py index 918034a0..c8e68720 100644 --- a/old_projects/nn/playground.py +++ b/old_projects/nn/playground.py @@ -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 * diff --git a/old_projects/patreon.py b/old_projects/patreon.py index 111e7f68..e5643cf4 100644 --- a/old_projects/patreon.py +++ b/old_projects/patreon.py @@ -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 * diff --git a/old_projects/putnam.py b/old_projects/putnam.py index 809c821a..302db6f7 100644 --- a/old_projects/putnam.py +++ b/old_projects/putnam.py @@ -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 * diff --git a/old_projects/qa_round_two.py b/old_projects/qa_round_two.py index 0aa2774c..a1ef9fdf 100644 --- a/old_projects/qa_round_two.py +++ b/old_projects/qa_round_two.py @@ -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 * diff --git a/old_projects/tattoo.py b/old_projects/tattoo.py index 502cedce..60b43aa2 100644 --- a/old_projects/tattoo.py +++ b/old_projects/tattoo.py @@ -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 * diff --git a/old_projects/triangle_of_power/end.py b/old_projects/triangle_of_power/end.py index a795ee33..7abb3289 100644 --- a/old_projects/triangle_of_power/end.py +++ b/old_projects/triangle_of_power/end.py @@ -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 * diff --git a/old_projects/triangle_of_power/intro.py b/old_projects/triangle_of_power/intro.py index f9768221..11f4ab90 100644 --- a/old_projects/triangle_of_power/intro.py +++ b/old_projects/triangle_of_power/intro.py @@ -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 * diff --git a/old_projects/triangle_of_power/triangle.py b/old_projects/triangle_of_power/triangle.py index 01387f9d..42d19266 100644 --- a/old_projects/triangle_of_power/triangle.py +++ b/old_projects/triangle_of_power/triangle.py @@ -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 * diff --git a/old_projects/triples.py b/old_projects/triples.py index a9bead15..82d055dc 100644 --- a/old_projects/triples.py +++ b/old_projects/triples.py @@ -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 * diff --git a/old_projects/uncertainty.py b/old_projects/uncertainty.py index 80ccc2c4..96451c52 100644 --- a/old_projects/uncertainty.py +++ b/old_projects/uncertainty.py @@ -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 * diff --git a/old_projects/waves.py b/old_projects/waves.py index 1315b446..104c6909 100644 --- a/old_projects/waves.py +++ b/old_projects/waves.py @@ -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 * diff --git a/old_projects/wcat.py b/old_projects/wcat.py index b72e1e45..a8d31b24 100644 --- a/old_projects/wcat.py +++ b/old_projects/wcat.py @@ -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 * diff --git a/old_projects/zeta.py b/old_projects/zeta.py index 064d2986..ef8f7f1c 100644 --- a/old_projects/zeta.py +++ b/old_projects/zeta.py @@ -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 * diff --git a/topics/characters.py b/topics/characters.py index 9e2a0dc1..f21d9675 100644 --- a/topics/characters.py +++ b/topics/characters.py @@ -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 diff --git a/topics/light.py b/topics/light.py index 587d9c08..9d3f0bfe 100644 --- a/topics/light.py +++ b/topics/light.py @@ -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 * diff --git a/topics/objects.py b/topics/objects.py index af9607c6..76a476b8 100644 --- a/topics/objects.py +++ b/topics/objects.py @@ -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, \