示例#1
0
def code_line(*args, language=None):
    out = VGroup(*[DraculaCode(text=text, language=language) for text in args])
    out.arrange(direction=RIGHT)
    return out
    def construct(self):
        super().construct()

        # Group first row and second row
        use_cases = []
        for use_case1, use_case2 in zip(USE_CASES, USE_CASES[5:]):
            use_case2.next_to(use_case1, DOWN, buff=0.5)
            use_cases.append(VGroup(use_case1, use_case2))
        use_cases = VGroup(*use_cases)

        # Make all use cases same width and height
        widest = sorted(use_cases, key=lambda x: x.width)[-1]
        tallest = sorted(chain.from_iterable(use_cases),
                         key=lambda x: x.height)[-1]
        for use_case_top, use_case_bottom in use_cases:
            use_case_top.frame.stretch_to_fit_width(widest.width)
            use_case_top.frame.stretch_to_fit_height(tallest.height)
            use_case_bottom.frame.stretch_to_fit_width(widest.width)
            use_case_bottom.frame.stretch_to_fit_height(tallest.height)

        use_cases.arrange().scale(0.8).center()

        # Human friendly names for use cases

        antibodies = use_cases[0][0]
        peptides_ppi = use_cases[0][1]

        toxins = use_cases[1][0]
        peptides_sol = use_cases[1][1]

        enzyme_stabilisation = use_cases[2][0]
        microbiome = use_cases[2][1]

        codons = use_cases[3][0]
        detoxification = use_cases[3][1]

        clinical = use_cases[4][0]
        mutation = use_cases[4][1]

        # --- Animate!

        # Create the use cases
        self.play(Write(use_cases))
        self.wait(1)

        # Example setting the camera
        old_width = self.camera.frame_width
        if self.zoom_each_use_case:
            for use_case in chain.from_iterable(use_cases):
                self.play(
                    self.camera.frame.animate.move_to(use_case).set(
                        width=use_case.width * 2))
                self.wait(2)

        self.play(
            self.camera.frame.animate.move_to(ORIGIN).set(width=old_width))
        self.wait(2)

        # Highlight groups with common / synergies
        # Indications to apply to group visually, temporarily, use cases
        # https://docs.manim.community/en/stable/reference/manim.animation.indication.html

        # Similar modalities (some of these are a bit of a stretch to group together)

        if self.all_groups_at_same_time:
            self.play(
                FocusOn(antibodies),
                # Peptides
                Wiggle(peptides_sol),
                Wiggle(peptides_ppi),
                # DNA + RNA
                Indicate(codons),
                Indicate(mutation),
                Indicate(clinical),
                # Proteins
                Circumscribe(toxins.frame),
                Circumscribe(detoxification.frame),
                # Enzyme
                ApplyWave(enzyme_stabilisation),
                ApplyWave(microbiome),
                run_time=3)
            self.wait(6)
示例#3
0
def code_group(*args, language=None):
    out = VGroup(*[code_line(*text, language=language) for text in args])
    out.arrange(direction=DOWN, center=False)
    for elm in out:
        elm.align_to(out.get_left(), direction=LEFT)
    return out