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

Code before:

    .. manim:: PolygonExample
        :save_last_frame:

        class PolygonExample(Scene):
            def construct(self):
                isosceles = Polygon([-5, 1.5, 0], [-2, 1.5, 0], [-3.5, -2, 0])
                position_list = [
                    [4, 1, 0],  # middle right
                    [4, -2.5, 0],  # bottom right
                    [0, -2.5, 0],  # bottom left
                    [0, 3, 0],  # top left
                    [2, 1, 0],  # middle
                    [4, 3, 0],  # top right
                ]
                square_and_triangles = Polygon(*position_list, color=PURPLE_B)
                self.add(isosceles, square_and_triangles)
    """

    def __init__(self, *vertices, color=BLUE, **kwargs):
        self.vertices = vertices
        super().__init__(color=color, **kwargs)

    def init_points(self):
        verts = self.vertices
        self.set_points_as_corners([*verts, verts[0]])

    generate_points = init_points

    def get_vertices(self):
        """Gets the vertices of the polygon.

        Examples
        --------
        ::

            >>> sq = Square()
            >>> points = sq.get_vertices()
            >>> points
            array([[ 1.,  1.,  0.],
                   [-1.,  1.,  0.],
                   [-1., -1.,  0.],
                   [ 1., -1.,  0.]])

        Returns
        -------
        :class:`numpy.ndarray`
            Returns a list of the coordinates of polygon's vertices.
        """

        return self.get_start_anchors()

Review comment (suggestion):
Did this *have* to be changed? Because I would prefer setting the corners in `__init__` instead, particularly because there could be confusion with `mob.vertices` and `mob.get_vertices()`, though that falls into a larger complaint about manim's architecture I have

Code after:
                    [0, 3, 0],  # top left
                    [2, 1, 0],  # middle
                    [4, 3, 0],  # top right
                ]
                square_and_triangles = Polygon(*position_list, color=PURPLE_B)
                self.add(isosceles, square_and_triangles)
    """

    def __init__(self, *vertices, color=BLUE, **kwargs):
        super().__init__(color=color, **kwargs)
        self.set_points_as_corners([*vertices, vertices[0]])

    def get_vertices(self):
        """Gets the vertices of the polygon.

        Examples
        --------
        ::

            >>> sq = Square()
            >>> points = sq.get_vertices()
            >>> points
            array([[ 1.,  1.,  0.],
                   [-1.,  1.,  0.],
                   [-1., -1.,  0.],
                   [ 1., -1.,  0.]])

        Returns
        -------
        :class:`numpy.ndarray`
            Returns a list of the coordinates of polygon's vertices.
        """

        return self.get_start_anchors()

    def round_corners(self, radius=0.5):
        """Rounds off the corners of the polygon.

        Parameters
        ----------
        radius : :class:`float`, optional
            The curvature of the corners of the polygon.

        Examples
        --------

        .. manim:: PolygonRoundCorners
            :save_as_gif:

            class PolygonRoundCorners(Scene):
                def construct(self):