Hello PIXIJS Devs.
I am working on Line of Sight in PIXIJS. So far my algo works well. I ecountered on issue, that i can not draw polygon which makes a hole inside a rectangle.
I tried to use mask and blend modes but it did not work.
this._lightGraphics.clear() beginFill(0x000000, 0.5) drawRect(0, 0, this.viewport.width, this.viewport.height) endFill() closePath() beginHole() drawPolygon(points) closePath() endHole()
I tried Graphics hole, it was working but not always, sometimes holes disapear for some reason.
Should be like this: (First image is using code above, but this is not working always) 2nd image shows there are 2 graphics (1 Rectangle which fits whole screen with black fill color and 0.5 alpha and second polygon (Vision))
I tried stacked canvas with blendMode multiply and it works.
What is the best way to do this?
Edit: Polygon is cleared and drawn each frame. Way to make hole inside rectangle needs to be fast.