Strange whitespace around shapes

I’m having trouble properly sizing shapes because they end up with a lot of whitespace around them.

I create a shape (StarNode, PolygonNode, or EllipseNode, then a TextNode. I resize both to the same dimensions. Then I put them into a GroupNode and finally resize the GroupNode the same.

The ellipse works perfectly, but star and polygon have significant whitespace.

While it looks alright, it makes proper sizing difficult.

Any thoughts on how I can make the size fit snugly around the shape? This is my first Figma plugin project and I’m likely missing something obvious.

I can provide the code if it will help.

That empty space is built into star and polygon because if you change the number of sides/points, it will still fit fine in the given area.

If you don’t need that empty space any longer (and don’t plan to change the number of sides/points) flatten the node with the plugin API: flatten · Figma Developers

Flattening the node will remove the whitespace.

1 Like

Thank you. Flatten is exactly what I need.

1 Like