Closed/stroked Path::intersectsLine() Q

Is there a way to see if a rectangle or line or other path intersects a closed, stroked path?

i’m running into this problem trying to fit a rectangle inside a path created with a roundedRect inside it and drawing using g.strokePath().

here’s my algorithm for finding the inside bounds, which is kind of brute-force-ish.

        Rectangle<float> innerBoundingBox = borderOutline.getBounds().toFloat().reduced(1.0f); //slightly inside our path
        while( true ) {
            Line<float> leftEdge(innerBoundingBox.getTopLeft(), innerBoundingBox.getBottomLeft());
            Line<float> topEdge(innerBoundingBox.getTopLeft(), innerBoundingBox.getTopRight());
            if( !borderOutline.intersectsLine(leftEdge) && !borderOutline.intersectsLine(topEdge) ) {
                break;
            }
            innerBoundingBox.reduce(1, 1);
        }

here’s what result i’m hoping to achieve all the time, where the red rectangle is entirely inside the path

here’s what happens some of the time:

here’s a 16 second clip of it in action and the flaws of the algorithm.

Basically, can we get a Path::strokedPathIntersectsLine() method?

Nope, that’d be a completely silly thing for a library to provide!

Just check whether it intersects either the stroked path OR the original centre path, and that will stop this edge-case, right?

it worked! That’s why you get paid the big bucks!

green is the original path. black is the stroked version.

edit:
spoke too soon:


:confused:

just additionally check whether the corners are inside the stroked path using contains() …?