One more

Click here to reveal my answer.

function test() {
  for (var i=0;i<12;i++) {
    polygon(6,180); rt(30)
  }
}

Can you generalise this to polygons(n)?

This is the result of polygons(8).

Click here to reveal my answer.

function polygons(n) {
  var k=n*2;
  var d=1000/n;
  for (var i=0;i<k;i++) {
    polygon(n,d);
    rt(360/k)
  }
}
function test() {
  polygons(8);
}

How did I come up with that d calculation - I must admit I used https://mycurvefit.com.