createLoop method

void createLoop(
  1. List<Vector2> vertices
)

Create a loop. This automatically adjusts connectivity.

The vertices are copied.

Implementation

void createLoop(List<Vector2> vertices) {
  assert(vertexCount == 0);
  assert(
    vertices.length >= 3,
    "A loop can't be created with less than 3 vertices",
  );
  this.vertices.addAll(vertices.map((Vector2 v) => v.clone()));
  _validateDistances(this.vertices);
  this.vertices.add(this.vertices[0].clone());
  prevVertex = this.vertices[vertexCount - 2];
  nextVertex = this.vertices[1];
  _hasPrevVertex = true;
  _hasNextVertex = true;
}