Jump to content

Mouse events on Bezier/curved line


buffonomics
 Share

Recommended Posts

I understand we cannot attach mouse listeners for Graphics lines right now.
But there have been work arounds for lines e.g creating a rectangle graphic and making that selectable.

What workarounds exist for attaching mouse events to bezier lines drawn with Graphics.bezierCurveTo?

I want to be able to hover and select a bezier line.

Link to comment
Share on other sites

There's no code for interaction of lines.

"GraphicsGeometry.containsPoint" has nothing about lines

You can try to do something about it . Every time this question was asked before, like https://github.com/pixijs/pixi.js/issues/6527 , nothing was done about it.

If you want to add it: basically, you can modify "GraphicsGeometry.containsPoint"  so it also iterates through lines and checks distance to all segments, that its less than lineWidth. Its not hard, its just nobody did that, or even if someone did it, it wasnt shared. Yes, that should work with bezierCurves too. Do you wanna be a hero?

Edited by ivan.popelyshev
Link to comment
Share on other sites

I've been working on some bezier controllers for my current project, and it is a bit of a minefield.

image.png.7ac764e6d93c7eb33bcd3f565da7ca94.png

The problem is you can get the x & y values from the value f (f is in the range 0,1) which represents how far it is along the curve, but, what is difficult and/or impossible depending on the complexity of your bezier is how to calculate the y value from the x. My curves are simple so I just did a brute force solution, but, for complex beziers there's more than one solution for a given x value.

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...