static void Subdivide(Random rand, Shape shape, int extraVertices)
{
int points = shape.Points.Length;
int assignedPoints = points - extraVertices;
while (assignedPoints < points) {
int p1 = rand.Next(0, assignedPoints);
if (p1 == assignedPoints - 1) {
shape.Points[assignedPoints] = Lerp(shape.Points[p1], shape.Points[0], 0.5f);
} else {
Array.Copy(shape.Points, p1 + 1, shape.Points, p1 + 2, assignedPoints - p1 - 1);
shape.Points[p1 + 1] = Lerp(shape.Points[p1], shape.Points[p1 + 2], 0.5f);
}
assignedPoints++;
}
}