Have you come across this thread yet?:
It’s not exactly polygons, but you can use the same logic to get the desired output.
Let me know if this is what you are looking for.