BooleanOps¶
声明
该部分从 ManimCommunity 借鉴得来
Union¶
-
class
manimlib.mobject.boolean_ops.
Union
(*vmobjects: manimlib.mobject.types.vectorized_mobject.VMobject, **kwargs)¶ 并集
传入两个及以上
VMobject
,返回它们并集的外轮廓初始化样式,VMobject 的样式有以下
fill
填充样式颜色:
fill_color
或color
不透明度:
fill_opacity
stroke
线条样式颜色:
stroke_color
或color
宽度:
stroke_width
不透明度:
stroke_opacity
gloss
光泽shadow
阴影reflectiveness
反光度
其中, color, opacity, width 属性均可以为一个列表,在渲染时会按照列表对其进行补间
UnionExample¶
class UnionExample(Scene):
def construct(self):
cir1 = Circle(radius=3).move_to(LEFT * 1.5)
cir2 = cir1.copy().move_to(RIGHT * 1.5)
u = Union(cir1, cir2, color=YELLOW, fill_opacity=0.4)
self.add(cir1, cir2, u)
Difference¶
-
class
manimlib.mobject.boolean_ops.
Difference
(subject: manimlib.mobject.types.vectorized_mobject.VMobject, clip: manimlib.mobject.types.vectorized_mobject.VMobject, **kwargs)¶ 差集
传入 submobject 和 clip,返回 submobject 裁去 clip 部分的轮廓线
初始化样式,VMobject 的样式有以下
fill
填充样式颜色:
fill_color
或color
不透明度:
fill_opacity
stroke
线条样式颜色:
stroke_color
或color
宽度:
stroke_width
不透明度:
stroke_opacity
gloss
光泽shadow
阴影reflectiveness
反光度
其中, color, opacity, width 属性均可以为一个列表,在渲染时会按照列表对其进行补间
DifferenceExample¶
class DifferenceExample(Scene):
def construct(self):
cir1 = Circle(radius=3).move_to(LEFT * 1.5)
cir2 = cir1.copy().move_to(RIGHT * 1.5)
d = Difference(cir1, cir2, color=YELLOW, fill_opacity=0.4)
self.add(cir1, cir2, d)
Intersection¶
-
class
manimlib.mobject.boolean_ops.
Intersection
(*vmobjects: manimlib.mobject.types.vectorized_mobject.VMobject, **kwargs)¶ 交集
传入两个及以上
VMobject
,返回它们交集的外轮廓初始化样式,VMobject 的样式有以下
fill
填充样式颜色:
fill_color
或color
不透明度:
fill_opacity
stroke
线条样式颜色:
stroke_color
或color
宽度:
stroke_width
不透明度:
stroke_opacity
gloss
光泽shadow
阴影reflectiveness
反光度
其中, color, opacity, width 属性均可以为一个列表,在渲染时会按照列表对其进行补间
IntersectionExample¶
class IntersectionExample(Scene):
def construct(self):
cir1 = Circle(radius=3).move_to(LEFT * 1.5)
cir2 = cir1.copy().move_to(RIGHT * 1.5)
i = Intersection(cir1, cir2, color=YELLOW, fill_opacity=0.4)
self.add(cir1, cir2, i)
Exclusion¶
-
class
manimlib.mobject.boolean_ops.
Exclusion
(*vmobjects: manimlib.mobject.types.vectorized_mobject.VMobject, **kwargs)¶ 补集
传入两个及以上
VMobject
,返回它们经过XOR
运算后图形的的外轮廓初始化样式,VMobject 的样式有以下
fill
填充样式颜色:
fill_color
或color
不透明度:
fill_opacity
stroke
线条样式颜色:
stroke_color
或color
宽度:
stroke_width
不透明度:
stroke_opacity
gloss
光泽shadow
阴影reflectiveness
反光度
其中, color, opacity, width 属性均可以为一个列表,在渲染时会按照列表对其进行补间
ExclusionExample¶
class ExclusionExample(Scene):
def construct(self):
cirs = VGroup(*[
Circle(radius=2).move_to(1.5 * np.array([
np.cos(i / 3 * TAU), np.sin(i / 3 * TAU), 0
])) for i in range(3)
])
e = Exclusion(*cirs, color=YELLOW, fill_opacity=0.4)
self.add(cirs, e)