Created
January 27, 2024 14:37
-
-
Save Aleksey-Danchin/e8d23a737e89f79c0aa17a0ea69b70db to your computer and use it in GitHub Desktop.
Булевые операции
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from manim import * | |
class Sample(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(RED).move_to(RIGHT) | |
bool_ops_text = Text("Булевые операции").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(FadeIn(i)) | |
self.play(i.animate.scale(0.25).move_to(RIGHT * 5 + UP * 2.5)) | |
intersection_text = Text("Пересечение", 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("Объединение", font_size=23) | |
self.play(FadeIn(u)) | |
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("Cимметричное\nвычитание", font_size=24) | |
self.play(FadeIn(e)) | |
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("Вычитание", font_size=23) | |
self.play( | |
d.animate.scale(0.3).next_to(u, LEFT, buff=difference_text.height * 3.5 + 1) | |
) | |
difference_text.next_to(d, UP) | |
self.play(FadeIn(difference_text)) | |
self.wait() | |
group = VGroup( | |
i, | |
intersection_text, | |
u, | |
union_text, | |
e, | |
exclusion_text, | |
d, | |
difference_text, | |
) | |
self.play(FadeOut(group, run_time=3, lag_ratio=0.1)) | |
self.play(FadeOut(ellipse_group)) | |
self.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment