表格

限定名称: 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。

参数:
  • table (Iterable[Iterable[float | str | 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 类。默认为 Paragraph。有关常见选择,请参阅 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

返回表格的垂直线。

刻度

按比例因子缩放大小。

set_column_colors

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

set_row_colors

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

属性

animate (动画)

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

animation_overrides (动画覆盖)

颜色

depth (深度)

mobject 的深度。

fill_color (填充颜色)

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

height (高度)

mobject 的高度。

n_points_per_curve (每条曲线的点数)

sheen_factor (光泽因子)

stroke_color (描边颜色)

width (宽度)

mobject 的宽度。

_add_horizontal_lines()[source]

向表格添加水平线。

返回类型:

表格

_add_labels(mob_table)[source]

向网格排列的 VGroup 添加标签。

参数:

mob_table (VGroup) – 一个以网格组织形式的 class:~.VGroup

返回:

返回添加了标签的 mob_table

返回类型:

V组

_add_vertical_lines()[source]

向表格添加垂直线

返回类型:

表格

_organize_mob_table(table)[source]

tableVMobject 排列成网格。

参数:

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

返回:

表格的 VMobject 已经以表格状网格排列在 VGroup 中。

返回类型:

V组

_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))。

参数:
  • table (Iterable[Iterable[float | str | VMobject]])

  • row_labels (Iterable[VMobject] | None)

  • col_labels (Iterable[VMobject] | None)

  • 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 (dict)

  • arrange_in_grid_config (dict)

  • line_config (dict)

_table_to_mob_table(table)[source]

table 的条目初始化为 VMobject

参数:

table (Iterable[Iterable[float | str | VMobject]]) – 一个二维数组或列表的列表。表格内容必须是 element_to_mobject 中可调用函数设定的有效输入。

返回:

table 条目生成的 VMobject 列表。

返回类型:

列表

add_background_to_entries(color=ManimColor('#000000'))[source]

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

参数:

color (ParsableManimColor)

返回类型:

表格

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

通过添加 BackgroundRectangle 来突出显示表格上特定位置的一个单元格。

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

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

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

返回类型:

表格

示例

示例: 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]

表格的自定义创建类型函数。

参数:
返回:

包含线条和元素创建的 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,不包括条目。

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

  • kwargs – 要传递给 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()[source]

返回表格的列标签。

返回:

包含表格列标签的 VGroup。

返回类型:

V组

示例

示例: 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 形式返回表格的列。

返回:

包含每个列的 VGroupVGroup

返回类型:

V组

示例

示例: 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 已设置,则返回一个特定条目。

参数:

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

返回:

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

返回类型:

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)[source]

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

参数:

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

返回:

包含表格所有条目(不包括标签)的 VGroup,如果 pos 已设置,则为给定位置的 VMobject

返回类型:

Union[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)[source]

返回给定位置单元格的 BackgroundRectangle

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

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

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

返回类型:

背景矩形

示例

示例: GetHighlightedCellExample

../_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()[source]

返回表格的水平线。

返回:

包含表格所有水平线的 VGroup

返回类型:

V组

示例

示例: 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()[source]

返回表格的标签。

返回:

包含表格所有标签的 VGroup

返回类型:

V组

示例

示例: 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()[source]

返回表格的行标签。

返回:

包含表格行标签的 VGroup

返回类型:

V组

示例

示例: 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()[source]

VGroupVGroup 形式返回表格的行。

返回:

包含每个行的 VGroupVGroup

返回类型:

V组

示例

示例: 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()[source]

返回表格的垂直线。

返回:

包含表格所有垂直线的 VGroup

返回类型:

V组

示例

示例: 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)[source]

按比例因子缩放大小。

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

参数:
  • scale_factor (float) – 缩放因子 \(\alpha\)。如果 \(0 < |\alpha| < 1\),mobject 将缩小;如果 \(|\alpha| > 1\),它将增大。此外,如果 \(\alpha < 0\),mobject 也会翻转。

  • scale_stroke – 布尔值,确定对象缩放时其轮廓是否也缩放。如果启用此选项,且轮廓为 2px 的对象按 0.5 因子缩放,则其轮廓将变为 1px。

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

返回:

自身

返回类型:

VMobject

示例

示例: MobjectScaleExample

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

class MobjectScaleExample(Scene):
    def construct(self):
        c1 = Circle(1, RED).set_x(-1)
        c2 = Circle(1, GREEN).set_x(1)

        vg = VGroup(c1, c2)
        vg.set_stroke(width=50)
        self.add(vg)

        self.play(
            c1.animate.scale(.25),
            c2.animate.scale(.25,
                scale_stroke=True)
        )
class MobjectScaleExample(Scene):
    def construct(self):
        c1 = Circle(1, RED).set_x(-1)
        c2 = Circle(1, GREEN).set_x(1)

        vg = VGroup(c1, c2)
        vg.set_stroke(width=50)
        self.add(vg)

        self.play(
            c1.animate.scale(.25),
            c2.animate.scale(.25,
                scale_stroke=True)
        )

另请参阅

move_to()

set_column_colors(*colors)[source]

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

参数:

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

返回类型:

表格

示例

示例: 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)[source]

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

参数:

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

返回类型:

表格

示例

示例: 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)