Design and make a component which can do following things - fix on window - measure the position of the spray part - calculate the next position where the spray part to move - change the line length to move the spary part to next position 
Design and make a component which can do following things