Moppel Posted February 13, 2019 Share Posted February 13, 2019 Last week I finished a paint brush tool (like in the good old MS paint ) and in order to get it running quite fast I am using a renderTexture print basically a path of circles such that it looks like a line. As soon as the user releases the pan-move, the tool emits the path (array of coordinates) which in turn gets rendered via the drawPolygon method of a pixi graphics (it looks much nicer and I is more performant than using circles again in a graphic). I totally avoid using beginFill()... basically only using the lineStyle before drawing the polygon. However, it seems that this is more or less only a border-decoration and cannot handle pointer-events (to let the user select these polylines and maybe remove them). Are there any solutions to this problem? A quickfix would be a trail of lineTo movements but since there is no lineCap, this looks pretty ugly Thanks in advance Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 13, 2019 Share Posted February 13, 2019 Yeah, that's the problem - interaction doesn't work with Graphics edges. There's no packaged solution for that, nor plugins. I have solutions in my projects that i dont want to publish. 1. (HARD) modify containsPoint that way if there are WebGL representation of Graphics available, check all of its triangle buffer, if they contain mouse position. 2. (SUPER-HARD) Implement LineCap, there is existing PR (thought its closed for some time) for pixijs v5. 3. (MY USUAL WORKDAY) Swap all the shaders that way they have mouse coord input and put object number in color in that pixel, then readPixels() it. Quote Link to comment Share on other sites More sharing options...
Exca Posted February 13, 2019 Share Posted February 13, 2019 You could also solve this by having objects with renderable = false that have a hitarea with an approximation of the coordinates, then listen to those objects and keep track of what maps to where. That way you could have single line tracked with a simple rectangular polygon. 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.