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

Code before:
                    )
                    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
    ):
        self.num_dashes = num_dashes
        self.positive_space_ratio = positive_space_ratio
        super().__init__(color=color, **kwargs)
        p = self.positive_space_ratio
        n = self.num_dashes
        if num_dashes > 0:
            # Assuming total length is 1
            dash_len = p / n
            if vmobject.is_closed():
                void_len = (1 - p) / n
            else:
                void_len = (1 - p) / (n - 1)

            self.add(
                *[
                    vmobject.get_subcurve(
                        i * (dash_len + void_len), i * (dash_len + void_len) + dash_len
                    )
                    for i in range(n)
                ]
            )
        # Family is already taken care of by get_subcurve
        # implementation
        if config.renderer == "opengl":
            self.match_style(vmobject, recurse=False)
        else:
            self.match_style(vmobject, family=False)


Review comment (bug):
I think this is wrong; this should be to compute the void length and not the dash len. 

As a visualization, look at the second example you attached with the PR : 
![image](https://user-images.githubusercontent.com/36239975/126537769-b5c44a4c-6699-4354-aadc-520fb3168ecd.png)

So, I think you just mixed but dash_len and void_len.


Code after:
                    )
                    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, dashed_ratio=0.5, color=WHITE, **kwargs
    ):
        self.num_dashes = num_dashes
        self.dashed_ratio = dashed_ratio
        super().__init__(color=color, **kwargs)
        r = self.dashed_ratio
        n = self.num_dashes
        if num_dashes > 0:
            # Assuming total length is 1
            dash_len = r / n
            if vmobject.is_closed():
                void_len = (1 - r) / n
            else:
                void_len = (1 - r) / (n - 1)

            self.add(
                *[
                    vmobject.get_subcurve(
                        i * (dash_len + void_len), i * (dash_len + void_len) + dash_len
                    )
                    for i in range(n)
                ]
            )
        # Family is already taken care of by get_subcurve
        # implementation
        if config.renderer == "opengl":
            self.match_style(vmobject, recurse=False)
        else:
            self.match_style(vmobject, family=False)