How to use the manimlib.mobject.svg.tex_mobject.TextMobject function in manimlib

To help you get started, we’ve selected a few manimlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Solara570 / demo-solara / calissons.py View on Github external
def initialize_texts(self):
        proof_texts = TextMobject("“证明”:", "涂颜色", "+", "换视角")
        proof_texts.arrange_submobjects(RIGHT)
        proof_texts.to_corner(LEFT+UP)

        imagine_3d_text = TextMobject("(想象这是一个三维图案...)")
        imagine_3d_text.to_corner(RIGHT+UP)
        imagine_3d_text.set_color(YELLOW)

        rhombi = VGroup(*[
            RhombusType(rhombus_config = {"fill_opacity" : 1})
            for RhombusType in (RRhombus, HRhombus, LRhombus)
        ])
        time_texts = VGroup(*[
            TexMobject("\\times", "n^2").scale(1.2).set_color(rhombus.get_fill_color())
            for rhombus in rhombi
        ])
        rhombi_and_texts = VGroup(*[
github Solara570 / demo-solara / custom / custom_mobjects.py View on Github external
def add_labels(self):
        numeral_labels = VGroup(*[
            TextMobject(str(i+1)).next_to(self.get_square("a"+str(i+1)), LEFT)
            for i in range(8)
        ])
        alphabetical_labels = TextMobject(*[chr(97+i) for i in range(8)])
        alphabetical_labels.next_to(self.border, DOWN, buff = 0.15)
        for i, label in enumerate(alphabetical_labels):
            label.next_to(self.get_square(chr(97+i)+"1"), DOWN, coor_mask = [1, 0, 0])
        self.add(numeral_labels, alphabetical_labels)
        self.numeral_labels = numeral_labels
        self.alphabetical_labels = alphabetical_labels
github Solara570 / demo-solara / short / ford_circles.py View on Github external
def add_remark(self):
        nl_text = TextMobject("数轴")
        nl_arrow = Arrow(ORIGIN, UP).match_height(nl_text)
        nl_remark = VGroup(nl_arrow, nl_text)
        nl_remark.scale(0.8)
        nl_remark.set_color(LIGHT_GREY)
        nl_remark.arrange_submobjects(RIGHT, buff = 0.1)
        nl_remark.next_to(self.axes.coords_to_point(0, 0), DOWN, buff = 0.1)
        nl_remark.to_edge(LEFT, buff = 0.15)
        frac_remark = TextMobject("圆内分数为圆心横坐标")
        frac_remark.scale(0.6)
        frac_remark.to_corner(DL, buff = 0.15)
        farey_sum_remark = TexMobject(
            "\\text{Farey Sum: }", "\\dfrac{a}{b} \\oplus \\dfrac{c}{d}", "=", "\\dfrac{a+c}{b+d}"
        )
        farey_sum_remark[1].set_color(YELLOW)
        farey_sum_remark[-1].set_color(PINK)
        farey_sum_remark.to_corner(DR, buff = 0.15)
github Solara570 / demo-solara / calissons.py View on Github external
def initialize_texts(self):
        geom_text = TextMobject("一个边长为$n$的正六边形", "和一些边长为1的菱形")
        eqtri_text = TextMobject("它们都是由若干正三角形组成的")
        three_types_text = TextMobject("因为朝向不同,菱形被分成三种")
        try_tiling_text = TextMobject("现在用这些菱形", "镶嵌", "正六边形...")
        remark = TextMobject("(无间隙且不重叠地覆盖)")
        claim_text = TextMobject("最终的图案中", "每种菱形的数量一定都是$n^2$")
        twist_text = TextMobject("改变菱形的摆放方式", "或者改变正六边形的大小", "这个结论依然成立")
        how_to_prove_text = TextMobject("如何证明?", "")
        
        for text in (geom_text, claim_text, twist_text):
            text.arrange_submobjects(DOWN, aligned_edge = LEFT)
        try_tiling_text[1].set_color(GREEN)
        remark.scale(0.5)
        remark.set_color(GREEN)
        remark.next_to(try_tiling_text[1], DOWN, buff = 0.1)
        how_to_prove_text.set_color(YELLOW)

        bg_texts = VGroup(
            geom_text,
            eqtri_text,
            three_types_text,
            VGroup(try_tiling_text, remark),
        )
        q_texts = VGroup(
github Elteoremadebeethoven / MyAnimations / omega_creature / omega_creature_class.py View on Github external
def get_bubble(self, *content, **kwargs):
        bubble_class = kwargs.get("bubble_class", ThoughtBubble)
        bubble = bubble_class(**kwargs)
        if len(content) > 0:
            if isinstance(content[0], str):
                content_mob = TextMobject(*content)
            else:
                content_mob = content[0]
            bubble.add_content(content_mob)
            if "height" not in kwargs and "width" not in kwargs:
                bubble.resize_to_content()
        bubble.pin_to(self)
        self.bubble = bubble
        return bubble
github 3b1b / manim / manimlib / for_3b1b_videos / common_scenes.py View on Github external
thanks.scale(0.9)
        thanks.next_to(black_rect.get_bottom(), UP, SMALL_BUFF)
        thanks.set_color(YELLOW)
        underline = Line(LEFT, RIGHT)
        underline.match_width(thanks)
        underline.scale(1.1)
        underline.next_to(thanks, DOWN, SMALL_BUFF)
        thanks.add(underline)

        changed_patron_names = list(map(
            self.modify_patron_name,
            self.specific_patrons,
        ))
        changed_patron_names.sort()
        patrons = VGroup(*map(
            TextMobject,
            changed_patron_names,
        ))
        patrons.scale(self.patron_scale_val)
        for patron in patrons:
            if patron.get_width() > self.max_patron_width:
                patron.set_width(self.max_patron_width)
        columns = VGroup(*[
            VGroup(*patrons[i::self.n_patron_columns])
            for i in range(self.n_patron_columns)
        ])
        for column in columns:
            for n, name in enumerate(column):
                name.shift(n * self.name_y_spacing * DOWN)
        columns.arrange(
            RIGHT, buff=LARGE_BUFF,
            aligned_edge=UP,
github 3b1b / manim / manimlib / for_3b1b_videos / common_scenes.py View on Github external
def get_supporter_note(self):
        return TextMobject(
            "(Available to supporters for review now)",
            color="#F96854",
        )
github 3b1b / manim / manimlib / for_3b1b_videos / common_scenes.py View on Github external
"alignment": "",
            "arg_separator": self.quote_arg_separator,
        }
        if isinstance(self.quote, str):
            if self.use_quotation_marks:
                quote = TextMobject("``%s''" %
                                    self.quote.strip(), **text_mobject_kwargs)
            else:
                quote = TextMobject("%s" %
                                    self.quote.strip(), **text_mobject_kwargs)
        else:
            if self.use_quotation_marks:
                words = [self.text_size + " ``"] + list(self.quote) + ["''"]
            else:
                words = [self.text_size] + list(self.quote)
            quote = TextMobject(*words, **text_mobject_kwargs)
            # TODO, make less hacky
            if self.quote_arg_separator == " ":
                quote[0].shift(0.2 * RIGHT)
                quote[-1].shift(0.2 * LEFT)
        for term, color in self.highlighted_quote_terms:
            quote.set_color_by_tex(term, color)
        quote.to_edge(UP, buff=self.top_buff)
        if quote.get_width() > max_width:
            quote.set_width(max_width)
        return quote
github 3b1b / manim / manimlib / mobject / svg / drawings.py View on Github external
def get_corner_numbers(self, value, symbol):
        value_mob = TextMobject(value)
        width = self.get_width() / self.card_width_to_corner_num_width
        height = self.get_height() / self.card_height_to_corner_num_height
        value_mob.set_width(width)
        value_mob.stretch_to_fit_height(height)
        value_mob.next_to(
            self.get_corner(UP + LEFT), DOWN + RIGHT,
            buff=MED_LARGE_BUFF * width
        )
        value_mob.set_color(symbol.get_color())
        corner_symbol = symbol.copy()
        corner_symbol.set_width(width)
        corner_symbol.next_to(
            value_mob, DOWN,
            buff=MED_SMALL_BUFF * width
        )
        corner_group = VGroup(value_mob, corner_symbol)
github Solara570 / demo-solara / calissons.py View on Github external
def initialize_texts(self):
        geom_text = TextMobject("一个边长为$n$的正六边形", "和一些边长为1的菱形")
        eqtri_text = TextMobject("它们都是由若干正三角形组成的")
        three_types_text = TextMobject("因为朝向不同,菱形被分成三种")
        try_tiling_text = TextMobject("现在用这些菱形", "镶嵌", "正六边形...")
        remark = TextMobject("(无间隙且不重叠地覆盖)")
        claim_text = TextMobject("最终的图案中", "每种菱形的数量一定都是$n^2$")
        twist_text = TextMobject("改变菱形的摆放方式", "或者改变正六边形的大小", "这个结论依然成立")
        how_to_prove_text = TextMobject("如何证明?", "")
        
        for text in (geom_text, claim_text, twist_text):
            text.arrange_submobjects(DOWN, aligned_edge = LEFT)
        try_tiling_text[1].set_color(GREEN)
        remark.scale(0.5)
        remark.set_color(GREEN)
        remark.next_to(try_tiling_text[1], DOWN, buff = 0.1)
        how_to_prove_text.set_color(YELLOW)

        bg_texts = VGroup(
            geom_text,
            eqtri_text,
            three_types_text,
            VGroup(try_tiling_text, remark),
        )