表格

限定名称: manim.mobject.table.Table

class Table(table, row_labels=None, col_labels=None, top_left_entry=None, v_buff=0.8, h_buff=1.3, include_outer_lines=False, add_background_rectangles_to_entries=False, entries_background_color=ManimColor('#000000'), include_background_rectangle=False, background_rectangle_color=ManimColor('#000000'), element_to_mobject=<class 'manim.mobject.text.text_mobject.Paragraph'>, element_to_mobject_config={}, arrange_in_grid_config={}, line_config={}, **kwargs)[source]

基础类: VGroup

一个在屏幕上显示表格的mobject。

Parameters:
  • 表格 (可迭代[可迭代[浮点数 | 字符串 | VMobject]]) – 一个二维数组或列表的列表。表格的内容必须是element_to_mobject中设置的可调用对象的有效输入。

  • row_labels (Iterable[VMobject] | None) – 表示每行标签的VMobject列表。

  • col_labels (Iterable[VMobject] | None) – 表示每列标签的VMobject列表。

  • top_left_entry (VMobject | None) – 表格的左上角条目,只有在提供了行和列标签时才能指定。

  • v_buff (float) – 传递给arrange_in_grid()的垂直缓冲区,默认值为0.8。

  • h_buff (float) – 传递给arrange_in_grid()的水平缓冲区,默认值为1.3。

  • include_outer_lines (bool) – True 如果表格应包含外边框,默认为 False。

  • add_background_rectangles_to_entries (bool) – True 如果应该为条目添加背景矩形,默认为 False

  • entries_background_color (ParsableManimColor) – 如果add_background_rectangles_to_entriesTrue,则条目的背景颜色。

  • include_background_rectangle (bool) – True 如果表格应该有背景矩形,默认为 False

  • background_rectangle_color (ParsableManimColor) – 如果 include_background_rectangleTrue,则为表格的背景颜色。

  • element_to_mobject (Callable[[float | str | VMobject], VMobject]) – 应用于表格条目的Mobject类。默认情况下为段落。常见选择请参见text_mobject/tex_mobject

  • element_to_mobject_config (dict) – 传递给 element_to_mobject 的自定义配置,默认为 {}。

  • arrange_in_grid_config (dict) – 传递给 arrange_in_grid() 的字典,用于自定义表格的排列方式。

  • line_config (dict) – 传递给 Line 的字典,用于自定义表格的线条。

  • kwargs – 传递给VGroup的额外参数。

示例

示例:TableExamples

../_images/TableExamples-2.png
from manim import *

class TableExamples(Scene):
    def construct(self):
        t0 = Table(
            [["This", "is a"],
            ["simple", "Table in \n Manim."]])
        t1 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        t1.add_highlighted_cell((2,2), color=YELLOW)
        t2 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")],
            top_left_entry=Star().scale(0.3),
            include_outer_lines=True,
            arrange_in_grid_config={"cell_alignment": RIGHT})
        t2.add(t2.get_cell((2,2), color=RED))
        t3 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")],
            top_left_entry=Star().scale(0.3),
            include_outer_lines=True,
            line_config={"stroke_width": 1, "color": YELLOW})
        t3.remove(*t3.get_vertical_lines())
        g = Group(
            t0,t1,t2,t3
        ).scale(0.7).arrange_in_grid(buff=1)
        self.add(g)
class TableExamples(Scene):
    def construct(self):
        t0 = Table(
            [["This", "is a"],
            ["simple", "Table in \n Manim."]])
        t1 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        t1.add_highlighted_cell((2,2), color=YELLOW)
        t2 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")],
            top_left_entry=Star().scale(0.3),
            include_outer_lines=True,
            arrange_in_grid_config={"cell_alignment": RIGHT})
        t2.add(t2.get_cell((2,2), color=RED))
        t3 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")],
            top_left_entry=Star().scale(0.3),
            include_outer_lines=True,
            line_config={"stroke_width": 1, "color": YELLOW})
        t3.remove(*t3.get_vertical_lines())
        g = Group(
            t0,t1,t2,t3
        ).scale(0.7).arrange_in_grid(buff=1)
        self.add(g)

示例:BackgroundRectanglesExample

../_images/BackgroundRectanglesExample-2.png
from manim import *

class BackgroundRectanglesExample(Scene):
    def construct(self):
        background = Rectangle(height=6.5, width=13)
        background.set_fill(opacity=.5)
        background.set_color([TEAL, RED, YELLOW])
        self.add(background)
        t0 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            add_background_rectangles_to_entries=True)
        t1 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            include_background_rectangle=True)
        g = Group(t0, t1).scale(0.7).arrange(buff=0.5)
        self.add(g)
class BackgroundRectanglesExample(Scene):
    def construct(self):
        background = Rectangle(height=6.5, width=13)
        background.set_fill(opacity=.5)
        background.set_color([TEAL, RED, YELLOW])
        self.add(background)
        t0 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            add_background_rectangles_to_entries=True)
        t1 = Table(
            [["This", "is a"],
            ["simple", "Table."]],
            include_background_rectangle=True)
        g = Group(t0, t1).scale(0.7).arrange(buff=0.5)
        self.add(g)

方法

add_background_to_entries

为表格的每个条目添加一个黑色的BackgroundRectangle

add_highlighted_cell

通过在表格的特定位置添加BackgroundRectangle来高亮显示一个单元格。

create

为表格定制的创建类型函数。

get_cell

返回一个特定的单元格作为一个矩形的Polygon,不包括入口。

get_col_labels

返回表的列标签。

get_columns

返回表的列作为VGroupVGroup

get_entries

返回表的各个条目(包括标签),如果设置了参数pos,则返回特定条目。

get_entries_without_labels

返回表的各个条目(不带标签),如果设置了参数pos,则返回特定条目。

get_highlighted_cell

返回给定位置单元格的BackgroundRectangle

get_horizontal_lines

返回表格的水平线。

get_labels

返回表的标签。

get_row_labels

返回表的行标签。

get_rows

返回表的行作为VGroupVGroup

get_vertical_lines

返回表格的垂直线。

scale

按比例缩放大小。

set_column_colors

为表格的每一列设置单独的颜色。

set_row_colors

为表格的每一行设置单独的颜色。

属性

animate

用于动画化self的任何方法的应用。

animation_overrides

color

depth

mobject的深度。

fill_color

如果有多种颜色(用于渐变),则返回第一个颜色

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

_add_horizontal_lines()[source]

向表格添加水平线。

Return type:

表格

_add_labels(mob_table)[source]

在网格排列的VGroup中添加标签。

Parameters:

mob_table (VGroup) – 一个在网格中组织的类:~.VGroup

Returns:

返回带有添加标签的mob_table

Return type:

VGroup

_add_vertical_lines()[source]

向表格添加垂直线

Return type:

表格

_organize_mob_table(table)[source]

tableVMobject排列在网格中。

Parameters:

表格 (可迭代[可迭代[VMobject]]) – 一个包含VMobject条目的二维可迭代对象。

Returns:

VMobjecttableVGroup 中已经排列成类似表格的网格。

Return type:

VGroup

_original__init__(table, row_labels=None, col_labels=None, top_left_entry=None, v_buff=0.8, h_buff=1.3, include_outer_lines=False, add_background_rectangles_to_entries=False, entries_background_color=ManimColor('#000000'), include_background_rectangle=False, background_rectangle_color=ManimColor('#000000'), element_to_mobject=<class 'manim.mobject.text.text_mobject.Paragraph'>, element_to_mobject_config={}, arrange_in_grid_config={}, line_config={}, **kwargs)

初始化自身。有关准确的签名,请参阅 help(type(self))。

Parameters:
  • 表格 (可迭代[可迭代[浮点数 | 字符串 | VMobject]])

  • row_labels (可迭代对象[VMobject] | )

  • col_labels (可迭代对象[VMobject] | )

  • top_left_entry (VMobject | None)

  • v_buff (float)

  • h_buff (float)

  • include_outer_lines (bool)

  • add_background_rectangles_to_entries (bool)

  • entries_background_color (ParsableManimColor)

  • include_background_rectangle (bool)

  • background_rectangle_color (ParsableManimColor)

  • element_to_mobject (Callable[[float | str | VMobject], VMobject])

  • element_to_mobject_config (字典)

  • arrange_in_grid_config (字典)

  • line_config (字典)

_table_to_mob_table(table)[source]

初始化 table 的条目为 VMobject

Parameters:

表格 (可迭代[可迭代[浮点数 | 字符串 | VMobject]]) – 一个二维数组或列表的列表。表格的内容必须是element_to_mobject中设置的可调用对象的有效输入。

Returns:

table的条目中获取的VMobject列表。

Return type:

列表

add_background_to_entries(color=ManimColor('#000000'))[来源]

为表格的每个条目添加一个黑色的BackgroundRectangle

Parameters:

颜色 (ParsableManimColor)

Return type:

表格

add_highlighted_cell(pos=(1, 1), color=ManimColor('#FFFF00'), **kwargs)[来源]

通过在表格的特定位置添加BackgroundRectangle来高亮显示一个单元格。

Parameters:
  • pos (Sequence[int]) – 表格中特定条目的位置。(1,1) 表示表格的左上角条目。

  • color (ParsableManimColor) – 用于突出显示单元格的颜色。

  • kwargs – 传递给BackgroundRectangle的额外参数。

Return type:

表格

示例

示例:AddHighlightedCellExample

../_images/AddHighlightedCellExample-1.png
from manim import *

class AddHighlightedCellExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.add_highlighted_cell((2,2), color=GREEN)
        self.add(table)
class AddHighlightedCellExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.add_highlighted_cell((2,2), color=GREEN)
        self.add(table)

create(lag_ratio=1, line_animation=<class 'manim.animation.creation.Create'>, label_animation=<class 'manim.animation.creation.Write'>, element_animation=<class 'manim.animation.creation.Create'>, entry_animation=<class 'manim.animation.fading.FadeIn'>, **kwargs)[source]

为表格定制的创建类型函数。

Parameters:
  • lag_ratio (float) – 动画的滞后比率。

  • line_animation (Callable[[VMobject | VGroup], 动画]) – 表格线条的动画样式,参见 creation 中的示例。

  • label_animation (Callable[[VMobject | VGroup], 动画]) – 表格标签的动画样式,参见 creation 中的示例。

  • element_animation (Callable[[VMobject | VGroup], 动画]) – 表格元素的动画样式,参见 creation 中的示例。

  • entry_animation (Callable[[VMobject | VGroup], 动画]) – 表格背景的进入动画,参见 creation 中的示例。

  • kwargs – 传递给创建动画的进一步参数。

Returns:

包含线条和元素创建的AnimationGroup。

Return type:

AnimationGroup

示例

示例:CreateTableExample

from manim import *

class CreateTableExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")],
            include_outer_lines=True)
        self.play(table.create())
        self.wait()
class CreateTableExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")],
            include_outer_lines=True)
        self.play(table.create())
        self.wait()

get_cell(pos=(1, 1), **kwargs)[source]

返回一个特定的单元格作为一个矩形的Polygon,不包括入口。

Parameters:
  • pos (Sequence[int]) – 表格中特定条目的位置。(1,1) 表示表格的左上角条目。

  • kwargs – 传递给Polygon的额外参数。

Returns:

多边形模仿表格中的一个特定单元格。

Return type:

Polygon

示例

示例:GetCellExample

../_images/GetCellExample-1.png
from manim import *

class GetCellExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        cell = table.get_cell((2,2), color=RED)
        self.add(table, cell)
class GetCellExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        cell = table.get_cell((2,2), color=RED)
        self.add(table, cell)

get_col_labels()[来源]

返回表的列标签。

Returns:

包含表格列标签的VGroup。

Return type:

VGroup

示例

示例:GetColLabelsExample

../_images/GetColLabelsExample-1.png
from manim import *

class GetColLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        lab = table.get_col_labels()
        for item in lab:
            item.set_color(random_bright_color())
        self.add(table)
class GetColLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        lab = table.get_col_labels()
        for item in lab:
            item.set_color(random_bright_color())
        self.add(table)

get_columns()[source]

返回表的列作为VGroupVGroup

Returns:

VGroup 包含 VGroup 中的每一列。

Return type:

VGroup

示例

示例:GetColumnsExample

../_images/GetColumnsExample-2.png
from manim import *

class GetColumnsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.add(SurroundingRectangle(table.get_columns()[1]))
        self.add(table)
class GetColumnsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.add(SurroundingRectangle(table.get_columns()[1]))
        self.add(table)

get_entries(pos=None)[source]

返回表的各个条目(包括标签),如果设置了参数pos,则返回特定条目。

Parameters:

pos (Sequence[int] | None) – 表格中特定条目的位置。(1,1) 表示表格的左上角条目。

Returns:

VGroup 包含表格的所有条目(包括标签) 或者如果设置了 pos,则返回给定位置的 VMobject

Return type:

Union[VMobject, VGroup]

示例

示例:GetEntriesExample

../_images/GetEntriesExample-2.png
from manim import *

class GetEntriesExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        ent = table.get_entries()
        for item in ent:
            item.set_color(random_bright_color())
        table.get_entries((2,2)).rotate(PI)
        self.add(table)
class GetEntriesExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        ent = table.get_entries()
        for item in ent:
            item.set_color(random_bright_color())
        table.get_entries((2,2)).rotate(PI)
        self.add(table)

get_entries_without_labels(pos=None)[来源]

返回表的各个条目(不带标签)或如果设置了参数pos,则返回特定条目。

Parameters:

pos (Sequence[int] | None) – 表格中特定条目的位置。(1,1) 表示表格的左上角条目(不包括标签)。

Returns:

VGroup 包含表格的所有条目(无标签) 或者如果设置了 pos,则为给定位置的 VMobject

Return type:

联合[VMobject, VGroup]

示例

示例:GetEntriesWithoutLabelsExample

../_images/GetEntriesWithoutLabelsExample-1.png
from manim import *

class GetEntriesWithoutLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        ent = table.get_entries_without_labels()
        colors = [BLUE, GREEN, YELLOW, RED]
        for k in range(len(colors)):
            ent[k].set_color(colors[k])
        table.get_entries_without_labels((2,2)).rotate(PI)
        self.add(table)
class GetEntriesWithoutLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        ent = table.get_entries_without_labels()
        colors = [BLUE, GREEN, YELLOW, RED]
        for k in range(len(colors)):
            ent[k].set_color(colors[k])
        table.get_entries_without_labels((2,2)).rotate(PI)
        self.add(table)

get_highlighted_cell(pos=(1, 1), color=ManimColor('#FFFF00'), **kwargs)[来源]

返回给定位置单元格的BackgroundRectangle

Parameters:
  • pos (Sequence[int]) – 表格中特定条目的位置。(1,1) 表示表格的左上角条目。

  • color (ParsableManimColor) – 用于突出显示单元格的颜色。

  • kwargs – 传递给BackgroundRectangle的额外参数。

Return type:

背景矩形

示例

示例:获取高亮单元格示例

../_images/GetHighlightedCellExample-1.png
from manim import *

class GetHighlightedCellExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        highlight = table.get_highlighted_cell((2,2), color=GREEN)
        table.add_to_back(highlight)
        self.add(table)
class GetHighlightedCellExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        highlight = table.get_highlighted_cell((2,2), color=GREEN)
        table.add_to_back(highlight)
        self.add(table)

get_horizontal_lines()[来源]

返回表格的水平线。

Returns:

VGroup 包含表格的所有水平线。

Return type:

VGroup

示例

示例:GetHorizontalLinesExample

../_images/GetHorizontalLinesExample-1.png
from manim import *

class GetHorizontalLinesExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.get_horizontal_lines().set_color(RED)
        self.add(table)
class GetHorizontalLinesExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.get_horizontal_lines().set_color(RED)
        self.add(table)

get_labels()[来源]

返回表的标签。

Returns:

VGroup 包含表格的所有标签。

Return type:

VGroup

示例

示例:GetLabelsExample

../_images/GetLabelsExample-1.png
from manim import *

class GetLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        lab = table.get_labels()
        colors = [BLUE, GREEN, YELLOW, RED]
        for k in range(len(colors)):
            lab[k].set_color(colors[k])
        self.add(table)
class GetLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        lab = table.get_labels()
        colors = [BLUE, GREEN, YELLOW, RED]
        for k in range(len(colors)):
            lab[k].set_color(colors[k])
        self.add(table)

get_row_labels()[来源]

返回表的行标签。

Returns:

VGroup 包含表格的行标签。

Return type:

VGroup

示例

示例:GetRowLabelsExample

../_images/GetRowLabelsExample-1.png
from manim import *

class GetRowLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        lab = table.get_row_labels()
        for item in lab:
            item.set_color(random_bright_color())
        self.add(table)
class GetRowLabelsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        lab = table.get_row_labels()
        for item in lab:
            item.set_color(random_bright_color())
        self.add(table)

get_rows()[来源]

返回表的行作为VGroupVGroup

Returns:

VGroup 包含每一行在一个 VGroup 中。

Return type:

VGroup

示例

示例:GetRowsExample

../_images/GetRowsExample-2.png
from manim import *

class GetRowsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.add(SurroundingRectangle(table.get_rows()[1]))
        self.add(table)
class GetRowsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.add(SurroundingRectangle(table.get_rows()[1]))
        self.add(table)

get_vertical_lines()[来源]

返回表格的垂直线。

Returns:

VGroup 包含表格的所有垂直线。

Return type:

VGroup

示例

示例:GetVerticalLinesExample

../_images/GetVerticalLinesExample-1.png
from manim import *

class GetVerticalLinesExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.get_vertical_lines()[0].set_color(RED)
        self.add(table)
class GetVerticalLinesExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")])
        table.get_vertical_lines()[0].set_color(RED)
        self.add(table)

scale(scale_factor, **kwargs)[来源]

按比例缩放大小。

默认行为是围绕mobject的中心进行缩放。

Parameters:
  • scale_factor (float) – 缩放因子 \(\alpha\)。如果 \(0 < |\alpha| < 1\),对象 会缩小,而对于 \(|\alpha| > 1\) 则会放大。此外, 如果 \(\alpha < 0\),对象也会被翻转。

  • kwargs – 传递给 apply_points_function_about_point()的额外关键字参数。

Returns:

self

Return type:

Mobject

示例

示例:MobjectScaleExample

../_images/MobjectScaleExample-2.png
from manim import *

class MobjectScaleExample(Scene):
    def construct(self):
        f1 = Text("F")
        f2 = Text("F").scale(2)
        f3 = Text("F").scale(0.5)
        f4 = Text("F").scale(-1)

        vgroup = VGroup(f1, f2, f3, f4).arrange(6 * RIGHT)
        self.add(vgroup)
class MobjectScaleExample(Scene):
    def construct(self):
        f1 = Text("F")
        f2 = Text("F").scale(2)
        f3 = Text("F").scale(0.5)
        f4 = Text("F").scale(-1)

        vgroup = VGroup(f1, f2, f3, f4).arrange(6 * RIGHT)
        self.add(vgroup)

另请参阅

move_to()

set_column_colors(*colors)[来源]

为表格的每一列设置单独的颜色。

Parameters:

colors (Iterable[ParsableManimColor]) – 一个可迭代的颜色集合;每种颜色对应一列。

Return type:

表格

示例

示例:SetColumnColorsExample

../_images/SetColumnColorsExample-2.png
from manim import *

class SetColumnColorsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")]
        ).set_column_colors([RED,BLUE], GREEN)
        self.add(table)
class SetColumnColorsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")]
        ).set_column_colors([RED,BLUE], GREEN)
        self.add(table)

set_row_colors(*colors)[来源]

为表格的每一行设置单独的颜色。

Parameters:

colors (Iterable[ParsableManimColor]) – 一个可迭代的颜色集合;每种颜色对应一行。

Return type:

表格

示例

示例:SetRowColorsExample

../_images/SetRowColorsExample-2.png
from manim import *

class SetRowColorsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")]
        ).set_row_colors([RED,BLUE], GREEN)
        self.add(table)
class SetRowColorsExample(Scene):
    def construct(self):
        table = Table(
            [["First", "Second"],
            ["Third","Fourth"]],
            row_labels=[Text("R1"), Text("R2")],
            col_labels=[Text("C1"), Text("C2")]
        ).set_row_colors([RED,BLUE], GREEN)
        self.add(table)