Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapshotCanvas function bug in CanvasRenderer #5792

Closed
rollinsafary-inomma opened this issue Jul 28, 2021 · 3 comments · Fixed by #5794
Closed

snapshotCanvas function bug in CanvasRenderer #5792

rollinsafary-inomma opened this issue Jul 28, 2021 · 3 comments · Fixed by #5794

Comments

@rollinsafary-inomma
Copy link

rollinsafary-inomma commented Jul 28, 2021

Version

  • Phaser Version: 3.55.2
  • Operating system: doesn't matter
  • Browser: doesn't matter

Description

Trying to get a snapshot from the container, when using Canvas Renderer. There seems a reference issue.

    snapshotCanvas: function (canvas, callback, getPixel, x, y, width, height, type, encoderOptions)
    {
        if (getPixel === undefined) { getPixel = false; }

        this.snapshotArea(x, y, width, height, callback, type, encoderOptions);

        var state = this.snapshotState;

        state.getPixel = getPixel;

        CanvasSnapshot(this.canvas, state);

        state.callback = null;

        return this;
    },

The function uses CanvasSnapshot(this.canvas, state); but there is no this.canvas property in there, there is canvas argument, that I think might be there or this.gameCanvas could be placed instead of this.canvas.

Example Test Code

  protected async generateImage(): Promise<
    Phaser.Display.Color | HTMLImageElement
  > {
    return new Promise<Phaser.Display.Color | HTMLImageElement>((resolve) => {
      const texture = this.add.renderTexture(
        0,
        0,
        this.gameObject.width,
        this.gameObject.height,
      );
      texture.draw(this.gameObject);
      texture.snapshot(resolve, 'image/png', 1);
    });
  }
}

Additional Information

samme added a commit to samme/phaser that referenced this issue Jul 28, 2021
@rollinsafary-inomma
Copy link
Author

@samme thanks for the fast fix. Is there any information on when this will be available?

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants