Repository: ManimCommunity/manim
File: manim/mobject/types/vectorized_mobject.py (Python)

Code before:

    """

    def __init__(self, vmobject, **kwargs):
        VGroup.__init__(self, **kwargs)
        tuples = vmobject.get_cubic_bezier_tuples()
        for tup in tuples:
            part = VMobject()
            part.set_points(tup)
            part.match_style(vmobject)
            self.add(part)


class DashedVMobject(VMobject, metaclass=ConvertToOpenGL):
    """

    Examples
    --------
    .. manim:: DashedVMobjectExample
        :save_last_frame:

        class DashedVMobjectExample(Scene):
            def construct(self):
                r = 0.5
                pos = 2.5 * UP + 6 * LEFT  # Tracker for position on screen
                # Top Row: Increases the number of dashes per iteration
                for dashes in range(2, 12):  # [2 , ..., 11]
                    circ = DashedVMobject(Circle(radius=r, color=WHITE), num_dashes=dashes).move_to(pos)
                    self.add(circ)
                    pos += 1.25 * RIGHT

                # Middle Row: Increasing Positive Space Ratio per iteration
                pos = 0.5 * UP + 6 * LEFT  # Reset Position
                for ratio in np.arange(1 / 11, 1, 1 / 11):  # [1/11 , ..., 10/11, 1]
                    circ = DashedVMobject(Circle(radius=r, color=WHITE), positive_space_ratio=ratio).move_to(pos)
                    self.add(circ)
                    pos += 1.25 * RIGHT

                # Bottom Row: Different Colors(Square and Pentagon)
                # Square
                pos = 1.5 * DOWN + 1.25 * LEFT  # Reset Position
                sq = DashedVMobject(Square(1.5, color=RED)).move_to(pos)

                # Pentagon
                pos += 2.5 * RIGHT
                penta = DashedVMobject(RegularPolygon(5, color=BLUE)).move_to(pos)

                self.add(sq, penta)

    """


Review comment (suggestion):
This could be shortened by created a `VGroup` called top row and appending the comment next to it. "Per iteration" also seems redundant here.

Code after:

    """

    def __init__(self, vmobject, **kwargs):
        VGroup.__init__(self, **kwargs)
        tuples = vmobject.get_cubic_bezier_tuples()
        for tup in tuples:
            part = VMobject()
            part.set_points(tup)
            part.match_style(vmobject)
            self.add(part)


class DashedVMobject(VMobject, metaclass=ConvertToOpenGL):
    """A :class:`VMobject` composed of dashes instead of lines.

    Examples
    --------
    .. manim:: DashedVMobjectExample
        :save_last_frame:

        class DashedVMobjectExample(Scene):
            def construct(self):
                r = 0.5

                top_row = VGroup()  # Increasing num_dashes
                for dashes in range(2, 12):
                    circ = DashedVMobject(Circle(radius=r, color=WHITE), num_dashes=dashes)
                    top_row.add(circ)

                middle_row = VGroup()  # Increasing positive_space_ratio
                for ratio in np.arange(1 / 11, 1, 1 / 11):
                    circ = DashedVMobject(
                        Circle(radius=r, color=WHITE), positive_space_ratio=ratio
                    )
                    middle_row.add(circ)

                sq = DashedVMobject(Square(1.5, color=RED))
                penta = DashedVMobject(RegularPolygon(5, color=BLUE))
                bottom_row = VGroup(sq, penta)

                top_row.arrange(buff=0.4)
                middle_row.arrange()
                bottom_row.arrange(buff=1)
                everything = VGroup(top_row, middle_row, bottom_row).arrange(DOWN, buff=1)
                self.add(everything)

    """

    def __init__(
        self, vmobject, num_dashes=15, positive_space_ratio=0.5, color=WHITE, **kwargs