Method to draw an open or closed polyline I'm writing a simple 2D rendering class.

Below is the method that creates a polyline. A polyline can be closed or not according to a parameter closed.

void Polyline(IList&lt;Point&gt; points, bool closed)
{
    var pointsCount = points.Count;
    if (pointsCount &lt; 2)
        return;

    int count = pointsCount;
    if (!closed)
        count = pointsCount - 1;

    for (int i1 = 0; i1 &lt; count; i1++)
    {
        int i2 = (i1 + 1) == pointsCount ? 0 : i1 + 1;
        Point p1 = points[i1];
        Point p2 = points[i2];
        AddLineSegment(p1, p2);
    }
}


But I think the parameter name closed is a little confusing. It may have two different meanings:


points have already closed the polyline: points[0] == point[points.Count-1]
points doesn't close the polyline and we will add the first point to rendered polyline in the method


I want to make it clear to users that the second is the right meaning. So what kind of name should I use?

I think closesIt or something similar should be better but it still sounds ambiguous. What's your opinion?
A closed polyline is really a polygon. For clarity, why not just call it a polygon?  There is no point in trying to do too much in the same function. Not only would the calling code be clearer, the implementations would be simpler too, without the special cases.

void Polyline(IList&lt;Point&gt; points)
{
    var n = points.Count - 1;
    for (int i = 0; i &lt; n; i++)
    {
        AddLineSegment(points[i], points[i + 1]);
    }
}

void Polygon(IList&lt;Point&gt; points)
{
    Polyline(points);
    if (points.Count &gt;= 3)
    {
        AddLineSegment(points[points.Count - 1], points[0]);
    }
}