I need to "fit" an arbitrarily shaped GraphicsPath into a defined space (almost always a Rectangle or Circle).
I currently scale the GraphicsPath using the Matrix object and the scaling works fine, but the problem is getting the scale factors.
The best technique I can come up with is converting the GraphicsPath to a Region, converting the Rectangle or Circle to a Region, and performing a:
rgnShape.Intersect(rgnCircle);
and then checking if:
rgnShape.IsEmpty()
However, this just tells me if the shape is too large to fit, and it becomes necessary to scale the shape smaller, and try again (possibly many, many times).
Is there an easy way to instantly calculate the scaling factors to fit a polygon GraphicsPath so that it fits entirely into a circle. The result should be the largest polygon that still fits completely within the circle.