react-lineto icon indicating copy to clipboard operation
react-lineto copied to clipboard

Arrow

Open kevkev-kev opened this issue 4 years ago • 3 comments

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?

kevkev-kev avatar Dec 11 '20 22:12 kevkev-kev

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.

stahlmanDesign avatar Jun 02 '21 16:06 stahlmanDesign

So we are never getting arrows in this library? @stahlmanDesign

piyushchauhan avatar Nov 06 '21 11:11 piyushchauhan

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.

stahlmanDesign avatar Nov 06 '21 13:11 stahlmanDesign