Pixi.js: Transparent Graphics cannot trigger click(v5.0.0-rc3)

Created on 24 Apr 2019  路  9Comments  路  Source: pixijs/pixi.js

But it's normal in v4.

demos:
v4
v5

Stale 馃憤 Not A Bug

Most helpful comment

I don't know how to fix that without breaking new v5 Graphics.

Workaround:

const g = new PIXI.Graphics()
    .beginFill(0xffcc33, 1.0)
  .drawRect(0, 0, 500, 500)
  .endFill()
g.alpha = 0.0;

All 9 comments

I don't know how to fix that without breaking new v5 Graphics.

Workaround:

const g = new PIXI.Graphics()
    .beginFill(0xffcc33, 1.0)
  .drawRect(0, 0, 500, 500)
  .endFill()
g.alpha = 0.0;

Probably, its new default behaviour and not a bug.

We have to mention it in changelist.

Thank you!

I doesn't feel good to have the inconsistency to have transparent graphics not register a click whilst transparent sprites do.

v5 Graphics logic:
Every shape has fill and stroke. Transparent fill = no fill. Transparent stroke = no stroke.

Got it

Graphics.js

const visible = alpha > 0;

if (!visible) {
  this._fillStyle.reset();
}

@ivanpopelyshev

GraphicsGeometry.js

I try to fix it in the following way:

GraphicsGeometry.prototype.containsPoint = function containsPoint (point)
{
    var graphicsData = this.graphicsData;

    for (var i = 0; i < graphicsData.length; ++i)
    {
        var data = graphicsData[i];

        /** === **/
        if (!data.fillStyle.visible && !data.fillStyle.alpha)
        /** === **/
        {
            continue;
        }
.....

Will there be any side effects?

Yes, remove whole "If" and "continue", try it.

Just in case, you'll have a problem with strokes. Maybe.

https://pixiplayground.com/#/edit/3MoUUu4MD8~ZGpY25LaK_

I removed the entire if statement and it looked OK. Affect performance?

Well, stroke only half works(like v4.).

FastStoneEditor1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gigamesh picture gigamesh  路  3Comments

SebastienFPRousseau picture SebastienFPRousseau  路  3Comments

YuryKuvetski picture YuryKuvetski  路  3Comments

st3v0 picture st3v0  路  3Comments

readygosports picture readygosports  路  3Comments