Regular Polygon Generator for Any Number of Sides

This is a showcase of a custom block I made. It can generate a regular polygon for a given number of sides, between 3 to 100.
Regular N-Sided Polygon Generator
For example, this is what it generates if you tell it to make a 5 sided shape:


It inherits the properties of the pen, similar to the text to costume library blocks. It also has a unique mode, which makes each side of the shape a different color. Here's what that looks like:

The color mode can look quite unique with a large number of sides. It makes a color wheel like this for side numbers of 100 and above:

It is somewhat limited, but can be quite helpful under the right circumstances. Thanks for reading, and make sure to check it out!

You forgot to say that it reports the shape as a costume! I was wondering why it was a reporter block until I read it carefully. :~)

Do you know about turtle geometry?

No.

Ah. Instead of all that trig stuff, to draw a regular polygon you can just

It's called "turtle geometry" because you're supposed to imagine that the sprite is a turtle, and the picture is described from its position and direction rather than by reference to an absolute (Cartesian) coordinate system. It makes drawing shapes much easier. (For example, experiment with 720 instead of 360 in the above code...)

Huh. I suppose that is easier, but wouldn't it be super difficult to calculate the overall size of the shape?
Like, if I wanted a 50 sided shape with a overall radius of 140 so it doesn't go off screen, that would be a ton of trial and error with that script to get the size correct.

Well, the perimeter is the product of the two inputs, SIDES and SIZE. So consider that a polygon, especially one with a large number of sides, is basically a circle, so just divide by 𝜋 to get the approximate diameter. (Or of course you could do it backwards if you start with the diameter of the shape you want.) I guess if you need a precise diameter it's harder.