futterbool Posted October 13, 2017 Share Posted October 13, 2017 Hi All, I'm trying to figure out if there is any functionality in PIXI to find a point on a bezier curve. For example I want to take a spurious global point and find the closest point on a curve. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 13, 2017 Share Posted October 13, 2017 That's all we have on bezier curves: https://github.com/pixijs/pixi.js/blob/dev/src/core/graphics/Graphics.js#L365 https://github.com/pixijs/pixi.js/blob/dev/src/core/graphics/utils/bezierCurveTo.js It converts path to polygon and then it you can do an estimation, just see what's stored in "graphics.graphicsData" and do some computations based on it. Quote Link to comment Share on other sites More sharing options...
m9dfukc Posted October 14, 2017 Share Posted October 14, 2017 I just needed the same functionality and found this http://pomax.github.io/bezierjs/ ... works pretty well combined with PIXI Quote Link to comment Share on other sites More sharing options...
futterbool Posted October 14, 2017 Author Share Posted October 14, 2017 3 hours ago, m9dfukc said: I just needed the same functionality and found this http://pomax.github.io/bezierjs/ ... works pretty well combined with PIXI @m9dfukc absolutely perfect, thank you very much. From a brief scan of the documents I take it you just recreated the curve in that library (just in memory, no visual) then used it for the mathematical calculations? Quote Link to comment Share on other sites More sharing options...
alex_h Posted October 15, 2017 Share Posted October 15, 2017 @m9dfukc I was also thinking about this very issue the other day, very useful - thanks! Quote Link to comment Share on other sites More sharing options...
m9dfukc Posted October 17, 2017 Share Posted October 17, 2017 On 14.10.2017 at 12:52 PM, futterbool said: @m9dfukc absolutely perfect, thank you very much. From a brief scan of the documents I take it you just recreated the curve in that library (just in memory, no visual) then used it for the mathematical calculations? yep, exactly. I actually use it together with https://opentype.js.org/ which spills out bezier curves for the outline of the font. I then feed these to bezierjs and "resample" along the outline with `.getLUT(steps)`. .getLUT(steps) 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.