Drawing a line which changes the legth.

I need to create a line that it changes it’s length.(As used in Entangled games). But I have no idea where to get started. I would really appreciate your help.

Thank you.