コード例 #1
0
    def write_bayes_rule(self):
        words = self.bayes_rule_words
        words_rect = SurroundingRectangle(words)
        rule = TexMobject("P(", "S", "|", "+", ")", "=", "P(", "S", ")", "{P(",
                          "+", "|", "S", ")", "\\over", "P(", "+", ")}")
        rule.highlight_by_tex("S", SICKLY_GREEN)
        rule.highlight_by_tex("+", YELLOW)
        rule.to_corner(UP + RIGHT)
        rule_rect = SurroundingRectangle(rule)
        rule_rect.highlight(BLUE)
        rule.save_state()
        rule.replace(words_rect)
        rule.scale_in_place(0.9)
        rule.set_fill(opacity=0)

        self.play(ShowCreation(words_rect))
        self.play(ReplacementTransform(words_rect, rule_rect),
                  rule.restore,
                  run_time=2)
        self.dither(3)
コード例 #2
0
ファイル: 08-paradoxes.py プロジェクト: hengfun/manim
    def construct(self):

        series = VideoSeries(num_videos=16).to_edge(UP)
        brace = Brace(VGroup(series[8:]), DOWN)
        series.save_state()
        series.behind_edge(UP)
        question = TextMobject("What can be a set")
        self.play(series.restore, GrowFromCenter(brace))
        self.play(Write(question))

        self.dither()
        #self.wait_to(11.5)
        self.play(FadeOut(brace), question.shift, 2 * DOWN)
        series_active = series.copy()
        series_active.highlight(YELLOW).shift(0.5 * DOWN)

        for i, icon in enumerate(series_active):
            chap_num = TexMobject(str(i + 1)).replace(icon, 1)
            chap_num.scale_in_place(0.7)
            icon.remove(icon[1])
            icon.add(chap_num)

        axiom_chap = series[8]
        axiom_chap.target = series_active[8]
        axiom_chap.save_state()

        self.play(MoveToTarget(axiom_chap))
        axiom_text = [
            "Axioms of set theory",
            "$\\bullet$ Rules",
            "$\\bullet$ Allowed constructions",
        ]
        axiom_text = VGroup([TextMobject(text) for text in axiom_text])
        axiom_text.arrange_submobjects(DOWN, aligned_edge=LEFT)
        tmp = axiom_text[0].copy().next_to(axiom_chap, DOWN)
        axiom_text.shift(tmp.get_center() - axiom_text[0].get_center())

        for ax, t in zip(axiom_text, (15, 18, 25)):
            #self.wait_to(t)
            self.play(FadeIn(ax), submobject_mode="lagged_start")

        #self.wait_to(39)
        self.play(
            FadeOut(axiom_text),
            axiom_chap.restore,
        )
        objects = [
            "Matching",
            "Ordering",
            "Ordinal numbers",
            "Real numbers",
            "Cardinal numbers",
        ]
        objects = VGroup([TextMobject(text) for text in objects])
        objects.arrange_submobjects(DOWN)
        objects.next_to(series, DOWN)

        objects[2].next_to(series[10],
                           DOWN,
                           coor_mask=X_MASK,
                           aligned_edge=RIGHT)
        objects[4].to_edge(RIGHT)
        print([(obj, coef)
               for obj, coef in zip(objects[2:], (0.5, -1.0, 0.5))])
        objects[3].shift(X_MASK * sum([
            obj.get_edge_center(RIGHT) * coef
            for obj, coef in zip(objects[2:], (0.5, -1.0, 0.5))
        ]))
        objects[0].shift(2 * LEFT)
        objects[1].shift(1 * LEFT)

        lines = [
            Line(objects[0], series_active[9], buff=0.2),
            Line(objects[1],
                 series_active[9].get_edge_center(DOWN) + 0.2 * LEFT,
                 buff=0.2),
        ]
        for obj, i in zip(objects[2:], (10, 11, 15)):
            p1 = series_active[i].get_edge_center(DOWN)
            p0 = obj.get_corner(UP + RIGHT)
            p0 = p0 * Y_MASK + p1 * X_MASK
            lines.append(Line(p0, p1, buff=0.2))

        #self.wait_to(42.5)
        self.play(FadeIn(objects[2], submobject_mode="lagged_start"))
        #self.wait_to(50)
        self.play(
            ShowCreation(lines[2]),
            Transform(series[10], series_active[10]),
        )

        #self.wait_to(52)
        self.play(
            FadeIn(objects[4]),
            ShowCreation(lines[4]),
            Transform(series[15], series_active[15]),
        )
        #self.wait_to(54)
        self.play(
            FadeIn(objects[0]),
            ShowCreation(lines[0]),
            Transform(series[9], series_active[9]),
            run_time=0.5,
        )
        self.play(
            FadeIn(objects[3]),
            ShowCreation(lines[3]),
            Transform(series[11], series_active[11]),
        )
        self.play(
            FadeIn(objects[1]),
            ShowCreation(lines[1]),
        )

        self.dither(2)