예제 #1
0
    def __init__(self, source, target):
        matching_line = Line(0.5 * DOWN, 0.5 * UP)

        def matched_objects(source, target):
            matched = VGroup(source.copy(), matching_line.copy(),
                             target.copy())
            matched.arrange_submobjects(direction=DOWN)
            return matched

        final_mobj = VGroup(
            *(matched_objects(s, t)
              for (s, t) in zip(source.submobjects, target.submobjects)))
        self.buff = 2 * DEFAULT_MOBJECT_TO_MOBJECT_BUFFER
        final_mobj.arrange_submobjects(buff=self.buff)
        final_mobj.center()

        def match_animation(source, target, matched):
            return AnimationGroup(Transform(source, matched.submobjects[0]),
                                  ShowCreation(matched.submobjects[1]),
                                  Transform(target, matched.submobjects[2]))

        self.match_animations = [
            match_animation(s, t, m) for (s, t, m) in zip(
                source.submobjects, target.submobjects, final_mobj.submobjects)
        ]
        self.matching = VGroup(*[mob[1] for mob in final_mobj])
예제 #2
0
    def get_order_n_self(self, order):
        if order == 0:
            result = self.get_seed_shape()
        else:
            lower_order = self.get_order_n_self(order - 1)
            subparts = [lower_order.copy() for x in range(self.num_subparts)]
            self.arrange_subparts(*subparts)
            result = VGroup(*subparts)

        result.scale_to_fit_height(self.height)
        result.center()
        return result
예제 #3
0
    def get_order_n_self(self, order):
        if order == 0:
            result = self.get_seed_shape()
        else:
            lower_order = self.get_order_n_self(order - 1)
            subparts = [
                lower_order.copy()
                for x in range(self.num_subparts)
            ]
            self.arrange_subparts(*subparts)
            result = VGroup(*subparts)

        result.scale_to_fit_height(self.height)
        result.center()
        return result