elastic rectangle for selection

Good morning

a have a plane surface in 2d and many Points in this plane , i want to create a elastic rectangle who enable me to selecta points.

elastic rectangle like that of paint

thank you

A easy way to do this is to capture the current screen to a texture; then repeatedly draw this texture as a background with the rectangle on top until the mouse up event.