manim_zh_doc
  • 如何安装manim
  • 快速使用
  • 最佳实践
    • Basic Concepts
      • ManimCELogo
      • BraceAnnotation
      • VectorArrow
      • GradientImageFromArray
      • BooleanOperations
    • Animations
      • PointMovingOnShapes
      • MovingAround
      • MovingAngle
      • MovingDots
      • MovingGroupToDestination
      • MovingFrameBox
      • RotationUpdater
      • PointWithTrace
    • Plotting
      • SinAndCosFunctionPlot
      • ArgMinExample
      • GraphAreaPlot
      • PolygonOnAxes
      • HeatDiagramPlot
  • 教程 And 指导
    • 快速使用
      • 概述
      • 新建Project
      • 制作动画
      • 解释
      • 正方形转换圆
      • 定位Mobject
      • 使用.animate语法进行动画处理
      • Transform与ReplacementTransform
    • 输出设置
      • Manim 输出文件夹
      • 章节
      • 命令行标志
    • Manim 的构建块
      • Mobjects
        • 创建和显示 mobjects
        • 放置 mobjects
        • 设置 mobject 的样式
        • Mobject 屏幕顺序
      • 动画
        • 制作方法动画
        • 动画运行时间
        • 创建自定义动画
        • 使用 mobject 的坐标
        • 将 mobject 转换为其他 mobject
      • 场景
  • 进阶指南
    • 配置
      • 命令行参数
        • 高级示例
        • 所有 CLI 标志的列表
      • ManimConfig 类
      • 配置文件
    • 深入了解 Manim 的内部结构
      • 介绍
      • 概述
      • Page
Powered by GitBook
On this page
  1. 最佳实践
  2. Basic Concepts

BooleanOperations

Boolean 运算符

PreviousGradientImageFromArrayNextAnimations

Last updated 23 days ago

from manim import *

class BooleanOperations(Scene):
    def construct(self):
        ellipse1 = Ellipse(
            width=4.0, height=5.0, fill_opacity=0.5, color=BLUE, stroke_width=10
        ).move_to(LEFT)
        ellipse2 = ellipse1.copy().set_color(color=RED).move_to(RIGHT)
        bool_ops_text = MarkupText("<u>Boolean Operation</u>").next_to(ellipse1, UP * 3)
        ellipse_group = Group(bool_ops_text, ellipse1, ellipse2).move_to(LEFT * 3)
        self.play(FadeIn(ellipse_group))

        i = Intersection(ellipse1, ellipse2, color=GREEN, fill_opacity=0.5)
        self.play(i.animate.scale(0.25).move_to(RIGHT * 5 + UP * 2.5))
        intersection_text = Text("Intersection", font_size=23).next_to(i, UP)
        self.play(FadeIn(intersection_text))

        u = Union(ellipse1, ellipse2, color=ORANGE, fill_opacity=0.5)
        union_text = Text("Union", font_size=23)
        self.play(u.animate.scale(0.3).next_to(i, DOWN, buff=union_text.height * 3))
        union_text.next_to(u, UP)
        self.play(FadeIn(union_text))

        e = Exclusion(ellipse1, ellipse2, color=YELLOW, fill_opacity=0.5)
        exclusion_text = Text("Exclusion", font_size=23)
        self.play(e.animate.scale(0.3).next_to(u, DOWN, buff=exclusion_text.height * 3.5))
        exclusion_text.next_to(e, UP)
        self.play(FadeIn(exclusion_text))

        d = Difference(ellipse1, ellipse2, color=PINK, fill_opacity=0.5)
        difference_text = Text("Difference", font_size=23)
        self.play(d.animate.scale(0.3).next_to(u, LEFT, buff=difference_text.height * 3.5))
        difference_text.next_to(d, UP)
        self.play(FadeIn(difference_text))
253KB
BooleanOperations.mp4
BooleanOperations