react-lineto
react-lineto copied to clipboard
Arrow
I've been playing around with react-lineto and I really enjoy working with it. Thanks for putting this together!
Is there a way to add an arrow to one or both ends of the line?
I would say not easily, because you would need the angle of the line to correctly point an arrowhead, and I don't think that angle is exposed by the API. It might not even be available because the lines are drawn between DOM elements using css, and I think those calculations are outside of the scope of the lib/javascript.
So we are never getting arrows in this library? @stahlmanDesign
A quick look in the source code makes me think it would be possible because the angles are calculated and saved in a variable.
I once did this in a game using radians to get the angle of rotation based on a line. The character could shoot an arrow in the direction the mouse pointed (which was an invisible line from the character to the mouse pointer). The arrow was a sprite rotated to point in the direction it flew.
Here we could either have a sprite (svg arrow tip) or draw a triangle in the saw way the line is drawn. If I ever have time this would be a fun challenge.