Phaser API Documentation

  Version: 
snapshotArea(x, y, width, height, callback, [type], [encoderOptions])

Description:

Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered.

To capture the whole game viewport see the snapshot method. To capture a specific pixel, see snapshotPixel.

Only one snapshot can be active per frame. If you have already called snapshotPixel, for example, then calling this method will override it.

Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game.

Parameters:

name type arguments Default description
x number

The x coordinate to grab from.

y number

The y coordinate to grab from.

width number

The width of the area to grab.

height number

The height of the area to grab.

callback Phaser.Types.Renderer.Snapshot.SnapshotCallback

The Function to invoke after the snapshot image is created.

type string <optional> 'image/png'

The format of the image to create, usually image/png or image/jpeg.

encoderOptions number <optional> 0.92

The image quality, between 0 and 1. Used for image formats with lossy compression, such as image/jpeg.

Returns:
Description:

This WebGL Renderer.

Since: 3.16.0