BooleanOps¶
声明
该部分从 ManimCommunity 借鉴得来
Union¶

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¶

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¶

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¶

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)