当前位置: 首页>>代码示例>>Python>>正文


Python TextMobject.get_width方法代码示例

本文整理汇总了Python中mobject.tex_mobject.TextMobject.get_width方法的典型用法代码示例。如果您正苦于以下问题:Python TextMobject.get_width方法的具体用法?Python TextMobject.get_width怎么用?Python TextMobject.get_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mobject.tex_mobject.TextMobject的用法示例。


在下文中一共展示了TextMobject.get_width方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_title

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import get_width [as 别名]
 def add_title(self, title = "Sample space", buff = MED_SMALL_BUFF):
     title_mob = TextMobject(title)
     if title_mob.get_width() > self.get_width():
         title_mob.scale_to_fit_width(self.get_width())
     title_mob.next_to(self.full_space, UP, buff = buff)
     self.title = title_mob
     self.add(title_mob)
开发者ID:PythonJedi,项目名称:manim,代码行数:9,代码来源:probability.py

示例2: get_quote

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import get_width [as 别名]
 def get_quote(self, max_width = 2*SPACE_WIDTH-1):
     text_mobject_kwargs = {
         "alignment" : "",
         "arg_separator" : self.quote_arg_separator,
     }
     if isinstance(self.quote, str):
         quote = TextMobject("``%s''"%self.quote.strip(), **text_mobject_kwargs)
     else:
         words = ["``"] + list(self.quote) + ["''"]
         quote = TextMobject(*words, **text_mobject_kwargs)
         ##TODO, make less hacky
         quote[0].shift(0.2*RIGHT)
         quote[-1].shift(0.2*LEFT)
     for term, color in self.highlighted_quote_terms.items():
         quote.highlight_by_tex(term, color)
     quote.to_edge(UP)
     if quote.get_width() > max_width:
         quote.scale_to_fit_width(max_width)
     return quote
开发者ID:crclayton,项目名称:manim,代码行数:21,代码来源:common_scenes.py

示例3: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import get_width [as 别名]
    def construct(self):
        clock = Circle(radius = 2, color = WHITE)
        clock.add(Dot(ORIGIN))
        ticks = Mobject(*[
            Line(1.8*vect, 2*vect, color = GREY)
            for vect in compass_directions(12)
        ])
        clock.add(ticks)
        hour_hand = Line(ORIGIN, UP)
        minute_hand = Line(ORIGIN, 1.5*UP)
        clock.add(hour_hand, minute_hand)
        clock.to_corner(UP+RIGHT)
        hour_hand.get_center = lambda : clock.get_center()
        minute_hand.get_center = lambda : clock.get_center()
 
        solution = ImageMobject(
            "Newton_brachistochrone_solution2",
            use_cache = False
        )
        solution.stroke_width = 3
        solution.highlight(GREY)
        solution.scale_to_fit_width(5)
        solution.to_corner(UP+RIGHT)
        newton = ImageMobject("Old_Newton", invert = False)
        newton.scale(0.8)
        phil_trans = TextMobject("Philosophical Transactions")
        rect = Rectangle(height = 6, width = 4.5, color = WHITE)
        rect.to_corner(UP+RIGHT)
        rect.shift(DOWN)
        phil_trans.scale_to_fit_width(0.8*rect.get_width())
        phil_trans.next_to(Point(rect.get_top()), DOWN)
        new_solution = solution.copy()
        new_solution.scale_to_fit_width(phil_trans.get_width())
        new_solution.next_to(phil_trans, DOWN, buff = 1)
        not_newton = TextMobject("-Totally not by Newton")
        not_newton.scale_to_fit_width(2.5)
        not_newton.next_to(new_solution, DOWN, aligned_edge = RIGHT)
        phil_trans.add(rect)

        newton_complaint = TextMobject([
            "``I do not love to be",
            " \\emph{dunned} ",
            "and teased by foreigners''"
        ], size = "\\small")
        newton_complaint.to_edge(UP, buff = 0.2)
        dunned = newton_complaint.split()[1]
        dunned.highlight()
        dunned_def = TextMobject("(old timey term for making \\\\ demands on someone)")
        dunned_def.scale(0.7)
        dunned_def.next_to(phil_trans, LEFT)
        dunned_def.shift(2*UP)
        dunned_arrow = Arrow(dunned_def, dunned)

        johann = ImageMobject("Johann_Bernoulli2", invert = False)
        johann.scale(0.4)
        johann.to_edge(LEFT)
        johann.shift(DOWN)
        johann_quote = TextMobject("``I recognize the lion by his claw''")
        johann_quote.next_to(johann, UP, aligned_edge = LEFT)

        self.play(ApplyMethod(newton.to_edge, LEFT))
        self.play(ShowCreation(clock))
        kwargs = {
            "axis" : OUT,
            "rate_func" : smooth
        }
        self.play(
            Rotating(hour_hand, radians = -2*np.pi, **kwargs),
            Rotating(minute_hand, radians = -12*2*np.pi, **kwargs),
            run_time = 5
        )
        self.dither()
        self.clear()
        self.add(newton)
        clock.ingest_submobjects()
        self.play(Transform(clock, solution))
        self.remove(clock)
        self.add(solution)
        self.dither()
        self.play(
            FadeIn(phil_trans),
            Transform(solution, new_solution)
        )
        self.dither()
        self.play(ShimmerIn(not_newton))
        phil_trans.add(solution, not_newton)
        self.dither()
        self.play(*map(ShimmerIn, newton_complaint.split()))
        self.dither()
        self.play(
            ShimmerIn(dunned_def),
            ShowCreation(dunned_arrow)
        )
        self.dither()
        self.remove(dunned_def, dunned_arrow)
        self.play(FadeOut(newton_complaint))
        self.remove(newton_complaint)
        self.play(
            FadeOut(newton),
            GrowFromCenter(johann)
#.........这里部分代码省略.........
开发者ID:GodotMisogi,项目名称:manim,代码行数:103,代码来源:misc.py


注:本文中的mobject.tex_mobject.TextMobject.get_width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。