Online fills

I saw this flash game from Orisinal where you caught cute flies by drawing a grid around the flies with same colour. The they grew larger.

My question:

1: How do you draw and fill a shape at runtime

2: How do you check what’s inside the shapes boundaries ?

Any tutorials for such a thing out there ?