I have drawn polyshape geometry using lines. I want to move each line along mouse but in perpendicular direction. If line is parallel to x or y axis we can change x or y value according to that but if line is not parallel to x or y axis how to move that line in the perpendicular direction please. I am not getting any solution. So how to do that? Please find below image to the reffernce

# How to move line along with mouse but in perpendicular direction

Try to use the following fiddle as a code template:

https://jsfiddle.net/uLjtycpd/3/

Some mathematical background:

The idea is to compute a perpendicular vector for each line segment. You can then animate each segment along this vector.

3 Likes

Thank you so much for reply I will try this and update.

This post was flagged by the community and is temporarily hidden.

offset is calculating according to time but how to move line along mouse pointer. how to calculate offset according to mouse pointer? I am not getting yet.

how can I move line along mouse cursor?