Fill area with nearest color from boundary?

Hi everyone!
I would like to fill an enclosed area with the closest color from the boundary.

Something like:

  • Input: circle that is half red and half green.
  • Output: circle that is half filled in red and half in green

I googled for quite a bit and found some nice answers for other tools, for example Imagemagick:
imagemagick.org/discourse-se … 80#p138975

Does anyone have a suggestion how this can be done in TD?

Thanks!