Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow #43

Open
kevkev-kev opened this issue Dec 11, 2020 · 3 comments
Open

Arrow #43

kevkev-kev opened this issue Dec 11, 2020 · 3 comments

Comments

@kevkev-kev
Copy link

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?

@stahlmanDesign
Copy link

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.

@piyushchauhan
Copy link

piyushchauhan commented Nov 6, 2021

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

@stahlmanDesign
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants