Apologies if this is the wrong overflow to be posting this question to.
There was a certain control on a game one time that I thought was compelling. You select a unit and then drag the mouse around. As you’re dragging, an ant line is displayed from the unit to where the mouse pointer is. Then when you release the mouse button, you’re telling that unit to go to that position.
Can that now be done using JavaScript and canvas?
An ant line is like a dashed line where the dashes are rotating.
follow the mouse around throwing points into a point array (split them up into segments that represent your dotted line) and drawing line segments onto the canvas following those points. if you want some portion of the points to be transparent, just apply a paint that sets the line color to transparent for each alternate point segment. Have the drawing method sitting in an Timeout animation that swaps the order of the transparent paint and voila.
This tutorial should give you some ideas on how to draw the line.