buffonomics Posted December 9, 2020 Share Posted December 9, 2020 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 9, 2020 Share Posted December 9, 2020 (edited) 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 December 9, 2020 by ivan.popelyshev buffonomics 1 Quote Link to comment Share on other sites More sharing options...
charlie_says Posted December 9, 2020 Share Posted December 9, 2020 I've been working on some bezier controllers for my current project, and it is a bit of a minefield. 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. Quote Link to comment Share on other sites More sharing options...
buffonomics Posted December 9, 2020 Author Share Posted December 9, 2020 I would love to, with heavy guidance. It would be nice to see this solved once and for all. I will begin this when done with work today. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 9, 2020 Share Posted December 9, 2020 Its easier than you think. PixiJS already has those lines separated to segments Quote Link to comment Share on other sites More sharing options...
rockdaboot Posted April 16, 2021 Share Posted April 16, 2021 Hey all :-) Is there any progress on this ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.