Have never seen an out of the box solution for what you're trying to do.
One novel solution would be:
It would be fiddly and involve some math, though should be pretty robust, at least for shapes as complex as the one you've shown.