Jump to content

Pointerevents on unclosed polygon


Moppel
 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...