How to create nested polygon

I would suggest you write a function that stores - in two new global arrays - the midpoints of the next iteration, based on the current points in your existing global arrays.

Then you will have FOUR arrays. Two for the current polygon’s points, and two for the NEXT polygon’s points.

After you draw the first polygon, can you run a new function that overwrites the current points with the values from the next polygon’s?

float[] nextX;
float[] nextY;

void gen_next_points(){
  // TODO: Fill nextX and nextY with the right values.
}

void copy_values(){
  // TODO: move the values form nextX and nextY to px and py.
}
1 Like