Takes a snapshot of the given area of this Dynamic Texture.
The snapshot is taken immediately, but the results are returned via the given callback.
To capture the whole Dynamic Texture see the snapshot
method.
To capture just a specific pixel, see the snapshotPixel
method.
Snapshots work by using the WebGL readPixels
feature to grab every pixel from the frame buffer
into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally
creating an Image object from it, which is the image returned to the callback provided.
All in all, this is a computationally expensive and blocking process, which gets more expensive the larger the resolution this Dynamic Texture has, so please be careful how you employ this in your game.
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 |
encoderOptions | number | <optional> | 0.92 |
The image quality, between 0 and 1. Used for image formats with lossy compression, such as |
This Dynamic Texture instance.