作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
this is the thing I wanted to make
我是 manim 的新手,我正在尝试将文本放在一个矩形内,如图中所示我怎样才能做到这一点 ?? :(
最佳答案
您可以使用 VGroup
将框和文本组合在一起。
示例代码:
from manimlib import *
def create_textbox(color, string):
result = VGroup() # create a VGroup
box = Rectangle( # create a box
height=2, width=3, fill_color=color,
fill_opacity=0.5, stroke_color=color
)
text = Text(string).move_to(box.get_center()) # create text
result.add(box, text) # add both objects to the VGroup
return result
class TextBox(Scene):
def construct(self):
# create text box
textbox = create_textbox(color=BLUE, string="Hello world")
self.add(textbox)
# move text box around
self.play(textbox.animate.shift(2*RIGHT), run_time=3)
self.play(textbox.animate.shift(2*UP), run_time=3)
self.wait()
关于python - 如何在 Manim 社区中将文本放在矩形内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70142914/
我是一名优秀的程序员,十分优秀!