Shape Completion Test!?

Hi,
This task has been driving me crazy for the past two weeks…
I’m trying to figure out how to program a shape completion test and whether an object is inside that shape. I’m making a game where the goal is to draw a line around a moving opponent, trapping it inside.

Any ideas on how this can be done? If I end up using an idea/concept suggested by you, I’ll definitely credit in-game.

Thank you!